fix(uploader): only monitor the queue being idle when we kow we are finishing the upload #1521
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.
Regression from #1175
Fix for nextcloud/server#49287
Symptoms
This is a fix, but we could definitely improve here again, with the batchUpload method, things got messy.
But this would be technical debt, and the bug that this PR fixes is critical.
Explanations
By moving the idle listener to the end of the method, we are ensuring that the upload's job queue is fully populated before the reset can be triggered.
The original placement in the constructor meant the reset could happen before the upload was fully set up, causing the premature queue clearing we were experiencing. By moving it to the end of the upload method, we are guaranteeing that the queue is fully initialized before any potential reset can occur.
This is a great example of how event listener placement can critically impact the behavior of asynchronous operations