From 43b5d8e3a60a64484f2dc191009e0b3d4d274a50 Mon Sep 17 00:00:00 2001 From: nikita Date: Sun, 13 Sep 2026 03:28:27 +0300 Subject: [PATCH] Fixed downloader bugs related to temp file name --- src/mab/bot/_client_downloader.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/mab/bot/_client_downloader.py b/src/mab/bot/_client_downloader.py index 601b8ca..ad0a6e5 100644 --- a/src/mab/bot/_client_downloader.py +++ b/src/mab/bot/_client_downloader.py @@ -2,10 +2,8 @@ import asyncio import aiofiles import logging import os -import time import threading -import traceback -import random +from uuid import uuid4 from pathlib import Path import hashlib @@ -36,7 +34,7 @@ class ClientDownloader: config: MatrixBotConfig, client: AsyncClient) -> None: """ - Setup the sender. + Setup the downloader. Args: - config - config to use @@ -218,14 +216,12 @@ class ClientDownloader: if key is not None and iv is not None and sha256 is not None: # on disk if isinstance(result, Path): - r = unpaddedbase64.encode_base64(random.randbytes(8)) temp_path = result.with_name( - f".{result.name}.{int(time.time())}{r}.tmp" + f".{result.name}.{uuid4().hex}.tmp" ) await self._decrypt_file( result, temp_path, key, iv, sha256 ) - result.unlink() temp_path.replace(result) temp_path = None # in memory