Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions hydrogram/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,8 @@ async def handle_download(self, packet):
) = packet

None if in_memory else Path(directory).mkdir(parents=True, exist_ok=True)
temp_file_path = Path(directory).resolve() / file_name + ".temp"
file_path = Path(directory).resolve() / file_name
temp_file_path = file_path.with_suffix(".temp")
with BytesIO() if in_memory else Path(temp_file_path).open("wb") as file:
try:
async for chunk in self.get_file(
Expand All @@ -877,7 +878,6 @@ async def handle_download(self, packet):
file.name = file_name
return file
file.close()
file_path = Path(temp_file_path).suffix
shutil.move(temp_file_path, file_path)
return file_path

Expand Down