Report progress in validating downloads #3659
Merged
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.
Motivation
Changes
CKAN.Extensions.CryptoExtensions.ComputeHash
extension function supports progress updates from 0 to 100 via anIProgress
parameter and cancellation via a cancellation token (cancellation not used yet but could be taken advantage of in the future)NetFileCache.ZipValid
,NetFileCache.GetFileHashSha1
,NetFileCache.GetFileHashSha256
, andNetModuleCache.Store
also have anIProgress
parameter for reporting progress from 0 to 100 in each of their respective tasks.NetModuleCache.Store
scales and combines the updates from its sub-tasks in a 60:20:20 ratio forZipValid
:GetFileHashSha1
:GetFileHashSha256
, since that seems to be about how long they take in practice.NetFileCache.GetFileHashSha1
andNetFileCache.GetFileHashSha256
are mostly factored out into a new generic functionNetFileCache.GetFileHash<T>
that they callWait
tab uses aTableLayoutPanel
to manage the per-module progress barsIDownloader
has a newStoreProgress
event for reporting progress as it validates a ZIP fileNetAsyncModulesDownloader
fires itsStoreProgress
event in response to progress updates fromNetModuleCache.Store
StoreProgress
event to show a per-module progress bar while downloads are being validated so the user can see what's happeningAdditional fixes
With the major features of my ongoing network handling revamp completed, but mainly developed on Windows, I decided to take the master branch for a spin in an Ubuntu VM. I found myself on a very lively bug hunt, but understanding what was happening in various confusing cases required this PR's progress bars for ZIP validation, so I rebased and added the fixes here:
TaskCompletionSource
tells us when it's done, as in several existing spots.DownloadRow.Module
property toData
, but the grid was still looking forModule
. Now it's updated toData
.ResumingWebClient
finds that it already has the entire file in the in progress folder, it closes the stream, but Mono's WebClient seems to re-open it (whereas Windows leaves it closed), so now we also treat a download as unnecessary ifcontentLength
is 0EWOULDBLOCK
errors from [Bug][Solved] Mono.Unix.UnixIOException: Resource temporarily unavailable on Arch Linux after Util.Invoke and long chain of runtime calls #3343ModUpgrade
class's constructor no longer handled the parametersGUIMod
gave it correctly, now this is fixedWait.SetProgress
will no longer divide by 0 if you pass 0 in itstotal
paramManageMods.ModGrid
was renamed fromModList
in Master search bar and misc GUI clean-up #3041, but its event handlers still had aModList_
prefix; now they finally start withModGrid_
Repo.ModulesFromFile
\r\n
now useEnvironment.NewLine
instead to match the host platformKraken
classes are now markedreadonly
where possibleException.Message
, to make them easier to browse