As it is the progress control would create a hidden file in the outputDir of each download. This seems reasonable but would create situations as such:
A user starts to download two files https://server.etc/file1.zip and https://server.etc/file2.zip
One of the files is completed, but the other is not and the process is stopped
file1.zip progress file would be removed since it was completed
Restarting the download with the same command would re-download file1.zip unnecessarily (because it would have no progress file)
This PR suggests:
moving all progress files to a predictable location, a hidden directory under the user's directory (i.e. ~/.chunk)
all progress files names are unique to each combination of download URL and absolute local file path
This decision of uniqueness by URL and absolute file path allows the following scenarios:
I downloaded the file https://server.etc/file1.zip today to ~/2022-11/file.zip
If the server changes the contents of the file, for example, monthly, I can download the new version to ~/2022-12/file1.zip next month (this is exactly the use case for Minha Receita)
TODO in a follow up PR:
add a field on the Downloader struct to ignore existing progresses
add an option such as --discard-previous-downloads (terrible naming, any ideas?) to start a downloader deleting the ~/.chunk/ progress files related to that downloads.
As it is the
progress
control would create a hidden file in theoutputDir
of each download. This seems reasonable but would create situations as such:https://server.etc/file1.zip
andhttps://server.etc/file2.zip
file1.zip
progress file would be removed since it was completedfile1.zip
unnecessarily (because it would have no progress file)This PR suggests:
~/.chunk
)This decision of uniqueness by URL and absolute file path allows the following scenarios:
https://server.etc/file1.zip
today to~/2022-11/file.zip
~/2022-12/file1.zip
next month (this is exactly the use case for Minha Receita)TODO in a follow up PR:
Downloader
struct to ignore existing progresses--discard-previous-downloads
(terrible naming, any ideas?) to start a downloader deleting the~/.chunk/
progress files related to that downloads.