Fixed downloader bugs related to temp file name
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user