Fixed downloader bugs related to temp file name

This commit is contained in:
2026-09-13 03:28:27 +03:00
parent 0e9b621895
commit 43b5d8e3a6

View File

@@ -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