Fix progress bar hidden before the upload ends #9085
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.
Follow-up to #7056
Fixes issue mentioned in #6079 (comment) and #6079 (comment)
Fixes #8106
The jQuery File Upload plugin triggers the
stopevent once there are no more files being uploaded (even if some of them were added when another upload was already in progress). Therefore, the progress bar should be hidden in thefileuploadstopcallback.In some cases the
stopevent is not triggered and thus the progress bar is not hidden once no more files are being uploaded. This is caused by a race condition and it is fixed in #9245; except in buggy cases like that one (that need to be fixed anyway) it is safe to hide the progress bar in thefileuploadstopcallback.In any case, note that the callbacks in
fileuploaddonemay be called after thestopevent was triggered and handled when using chunked uploads. In that case once all the chunks are uploaded the assembled file is moved to its final destination, so its promise could be resolved after thestopevent was triggered. Therefore a different approach would be needed to keep the progress bar visible until the chunked upload is truly finished, but for the time being the current one is good enough.Before this pull request the progress bar was being hidden when the first upload finished, either successfully or with an error, no matter if there were other files being uploaded too.
The progress bar was being explicitly hidden also when the upload was cancelled. When an upload is cancelled all the single uploads are aborted, which triggers a
failevent for each of them. However, thestopevent is always triggered when no more files are being uploaded, so it is triggered too once all the single uploads were aborted. As all the single uploads are immediately aborted in a loop when the general upload is cancelled it makes no difference to hide the progress bar when the first single upload is aborted or when all the single uploads were aborted, so the progress bar is no longer explicitly hidden in the former case.