fix: handled Download states w.r.t Electron across app restarts #2490
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.
Closes #2489
Issue in brief
When the user pauses a download and then closes the app, on reopening the app they aren't able to
resume
the download or evenremove the download from list
!Suggested Fixes/Changes
Since in Electron, when the app is closed, automatically the
cancelled
state is triggered by electron for the DownloadItem, but unfortunately due to the abrupt quitting of the app by the user, thecancelled
state doesn't get updated properly in our data store!Hence in-order to tackle the above situation, I thought of changing the state of all the downloads (except
completed
ones) tocancelled
as the app starts and hence I've made the following change:APP_SETTINGS_LOADED
is called upon...status
andstate
tocancelled
if their previous states wereprogressing
orpaused
!paused
if the user had paused the download before closing the appprogressing
if the download was in progress while closing the appDemo of the above Suggested Changes
retry
the cancelled download and evenremove it from the list
!downloads-across-restarts.mp4