Multiple manual downloads, uncached filter, purge option #2930
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.
Problem
When you click the Download button in the mod info pane or right click a row and choose Download Contents, the GUI switches to the progress tab and begins downloading the module. The tabstrip is not locked down.
If you switch back to the mod list and initiate a second manual download while the first is still in progress, CKAN crashes with an exception like this:
Cause
Downloading is done by a
BackgroundWorker
, which can only handle one task at a time. When you start the second download, CKAN attempts to tell its worker to start up again while it's already active, which throws the exception.Changes
NetAsyncDownloader
is refactored to allow new downloads to be added to an in-progress group of downloadsNetAsyncDownloader
because it makes the class harder to maintain, and we have not lately solved any user problems by suggesting the "chicken bits" environment variable (I have not attempted to remove all of the cURL code from everywhere)NetAsyncModulesDownloader
is updated to exclude modules already being downloaded when starting new downloads, in case the user chooses Download Contents for the same module multiple times in a rowMainModInfo.ContentsDownloadButton_Click
andMain.downloadContentsToolStripMenuItem_Click
now both callMainModInfo.StartDownload
, which avoids trying to run the background worker if it's already busy and instead asksNetAsyncModulesDownloader
to add them to the current batchGUIMod
s instead ofCkanModule
s so their cached status can be updated properly after completionMinor stuff:
MainModInfo._PostModCaching
no longer callsRecreateDialogs
because this isn't needed and has nothing to do with downloading modulesMainModInfo.CacheWorker
is removed because this is private state that's not appropriate to shareTo make this more convenient to test:
Note that if you open the Cached filter and Purge Contents for some mod, it remains in the list, and the same goes for opening the Uncached filter and clicking Download Contents. I considered updating the filters after caching, but I think that might be confusing and annoying instead of helpful since a mod that you might have intended to work with further would disappear. The right click menu options should toggle their enabled status appropriately, though.
Fixes #1680.
Fixes #1713.
Fixes #2882.