2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 21:07:59 +00:00

Amend comment on shutil.move in download_worker

os.renames cannot move across drives/partitions on any platform.

that is why shutil.move is used, because the OS allotted temp file could
possibly be on another drive or partition.

Also fix code formatting on new import statements.
This commit is contained in:
Eric Blundell 2018-03-20 23:20:08 -05:00
parent 2cf2dd26f0
commit 8796e857af

View File

@ -35,9 +35,7 @@ from queue import Queue
from signal import signal, SIGINT, SIGTERM, SIGABRT from signal import signal, SIGINT, SIGTERM, SIGABRT
from threading import Event, Thread from threading import Event, Thread
import tempfile import tempfile
import shutil import shutil
import errno import errno
from pyrogram.api import functions, types from pyrogram.api import functions, types
@ -599,7 +597,7 @@ class Client:
else: else:
os.makedirs(os.path.dirname(file_name), exist_ok=True) os.makedirs(os.path.dirname(file_name), exist_ok=True)
# avoid errors moving between drives on windows # avoid errors moving between drives/partitions etc.
shutil.move(tmp_file_name, os.path.join(download_directory, file_name)) shutil.move(tmp_file_name, os.path.join(download_directory, file_name))
except OSError as e: except OSError as e:
log.error(e, exc_info=True) log.error(e, exc_info=True)