mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Check whether get_file failed or not #37
If it failed, also delete any eventual temporary file
This commit is contained in:
parent
440654a63f
commit
2b33f23990
@ -567,6 +567,9 @@ class Client:
|
|||||||
progress=progress
|
progress=progress
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if tmp_file_name is None:
|
||||||
|
return None
|
||||||
|
|
||||||
if file_name is not None:
|
if file_name is not None:
|
||||||
path[0] = "downloads/{}".format(file_name)
|
path[0] = "downloads/{}".format(file_name)
|
||||||
|
|
||||||
@ -2334,11 +2337,16 @@ class Client:
|
|||||||
if len(chunk) < limit:
|
if len(chunk) < limit:
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error(e)
|
raise e
|
||||||
finally:
|
finally:
|
||||||
cdn_session.stop()
|
cdn_session.stop()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error(e)
|
log.error(e)
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.remove(file_name)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
return file_name
|
return file_name
|
||||||
finally:
|
finally:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user