packt-cli / Packt-Publishing-Free-Learning

Scripts that automatically claim and download free daily eBooks from https://www.packtpub.com/packt/offers/free-learning

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

If a download is interrupted, unfinished files will prevent a new download

awegmann opened this issue · comments

Problem:

If you interrupt the application while downloading files (for example with CTRL-C), the unfinished downloads will stay in the destination directory. If you start the download again, the script will find a file with the expected name, but can not recognize, that this is not a fully downloaded ebook or code file.

Solution:

Start the download with a temporary file and after the file is fully downloaded, rename the file to the destination file name. If an exception occurs, clean up the temporary file.