knadh / tg-archive

A tool for exporting Telegram group chats into static websites like mailing list archives.
MIT License
834 stars 124 forks source link

Temporary file was not removed after failed download #78

Closed qk-li closed 1 year ago

qk-li commented 2 years ago

After enconcting download error eg. "The file reference has expired and is not no longer valid or it belongs to self-destructing media and cannot be resent (caused by GetFileRequest)", the partially downloaded temporary file will not be deleted.

knadh commented 2 years ago

This is a message from Telegram. Is the sync breaking at that point or does it continue to work?

qk-li commented 2 years ago

This is a message from Telegram. Is the sync breaking at that point or does it continue to work?

The sync continues on next id, but the unfinished temporary files is left over under /tmp. I have a quite unstable Internet here. I guess this error may come from that.

I am not familiar with Python, but just had a quick glance at the code to download media file: https://github.com/knadh/tg-archive/blob/ba72969d4e0200f5b417c498f5969028725e52cb/tgarchive/sync.py#L315-L322 I assume if download_media call to Telethon goes wrong during downloading, no filename will be returned here. So there is nothing to be moved to the media_dir and temporary file remains.