-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
More cleanup of download management related code in ContentManager #1045
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In theory, a book recorded in a local library may have only its url defined (and no path to a ZIM file). Such a book qualifies as downloadable too. That's why the call to `ContentManager::getRemoteOrLocalBook()` (which may return a "local" book) perfectly makes sense in `ContentManager::downloadBook()`. However, it doesn't then make sense to raise an error if the returned book turns out to be a "local" one. It would be more logical to request only for a remote book and report an error if that operation fails.
Inlined ContentManagerModel::startDownload() into ContentManager::downloadBook().
Now there is a single timer in ContentManager shared by all pending downloads. Temporarily, all active downloads are updated on every firing of the timer and this happens in the main thread. This will be changed later. The main objective of this change is to get rid of the timer in DownloadState so that it can be converted to a dumb struct set by ContentManager.
DownloadState::update() no longer calls ContentManager::updateDownloadInfos()
The commit "Moved download deregistration to ContentManager" introduced a bug - completed downloads were not properly deregistered. Note that a simpler fix by adding a single `m_downloads.remove(bookId);` line in `ContentManager::downloadCompleted()` didn't work (which means that that function is not always called upon download completion). I am not going to investigate that issue now, hoping that it will be automatically resolved once the redesign of download management is finished.
Now ContentManager::updateDownloadInfos() is called directly by ContentManager (rather than indirectly via ContentManagerModel).
... by inlining it into ContentManager::updateDownload()
veloman-yunkan
force-pushed
the
refactoring
branch
from
March 1, 2024 16:42
c03e0de
to
5d28f8a
Compare
mgautierfr
approved these changes
Mar 7, 2024
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.
LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is the next batch of changes extracted from #1038 and a follow-up to #1041.
The ugliest design issue that is solved by this PR is the convoluted download update operation:
ContentManagerModel::updateDownload()
which then callsDownloadState::update()
which callsContentManager::updateDownloadInfos()
whichContentManagerModel
Now the entire logic of the download update operation is concentrated in the
ContentManager::updateDownload()
method in a comprehensible way.The main user-observable change is that now there is a single timer for download updates - when it fires all active downloads are updated.
Also fixed a bug introduced in the previous PR that resulted in the download progress not working for the first row.