-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make --archive save the links to the downloaded songs as soon as the songs are downloaded. Closes #2196 #2220
base: dev
Are you sure you want to change the base?
Conversation
Thanks @Shajal-Kumar - I've changed the base to |
@Silverarmor I've resolved the conflicts in |
Hi @Silverarmor, I wanted to follow up and ask if there are any other changes that I need to make. |
I've requested a code review from @xnetcat who will look into it when they are free :) |
This won't save the data incrementally. You would have to move the add entry code to the search and download function, while making sure that only one thread has access to the file at the time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as stated in the comment
Hello @xnetcat, I'll make the required changes to the |
Title
Write downloaded songs to the archive file incrementally to prevent data loss on interruption
or
Make --archive save the links to the downloaded songs as soon as the songs are downloaded #2196
Description
This PR modifies the download/downloader.py and utils/archive.py modules to ensure that the archive file is created as soon as the script runs and updated incrementally. The
initialize
andadd_entry
methods have been added to archive.py to create the archive file if it does not already exist and add an entry to the archive file while flushing it immediately, respectively. Additionally, thedownload_multiple_songs
method in theDownloader
class has been updated to calladd_entry
as soon as each song is successfully downloaded. This change ensures that even if the download process is interrupted, the archive file will contain the URLs of all songs downloaded up to that point.Related Issue
This change addresses issue #2196 where the archive file was not being updated during the download process, causing data loss if the process was interrupted.
Motivation and Context
This change is necessary to prevent data loss when using the
--archive
flag. Previously, the archive file was not created at the beginning of the script and if the download was interrupted, the archive file remained empty, even if most of the songs had been downloaded. By writing to the archive file incrementally, we ensure that users have an up-to-date record of all successfully downloaded songs, even in case of an unexpected interruption.How Has This Been Tested?
Manually tested by downloading a playlist with songs that would not be present on the download source and interrupting the process at various points to ensure the archive file contains all URLs of downloaded songs.
Verified that the archive file is created at the start of the download process and updated immediately after each successful download.
Screenshots (if appropriate)
Types of Changes
Checklist