fix(validation) report status of checked segments, not just completed#661
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
During NZB import, the queue progress bar sits frozen at "Validating segments 30%" for the entire validation phase, then jumps straight to completed or failed. For incomplete files (segments missing on the provider) it can appear stuck for seconds to minutes, which is indistinguishable from a hang.
The 30% value is not real progress. It is a fixed stage marker set in
internal/importer/processor.goright before validation begins:Validation then owns the 30→100% band via a tracker created with
CreateTracker(queueID, 30, 100). Real progress within that band is computed ininternal/progress/tracker.go:Root cause
In
ValidateSegmentList, the progress counter only incremented after a successfulStat. A failed segment returned early and never reached the update:So when a file's articles are missing,
validatedCountstays at 0 and the math resolves to30 + 0*70/total = 30%for the whole run. The bar literally cannot move until a segment succeeds.This matters because the pool is built with
WithErrors().WithFirstError()and no context cancellation, so it STATs every selected segment even after the first failure. The work is happening; the UI just had no way to reflect it.The change
Count every segment that has been checked (pass or fail) rather than only successes. The update is moved into a
deferso it always fires when the goroutine returns, regardless of theStatoutcome.Walkthrough the changes:
validatedCounttocheckedCount. The counter now tracks segments checked, not segments that passed. Renamed so the name matches the meaning.deferat the top of the closure. Deferring guarantees it runs on every return path, including the earlyreturnwhenStatfails. This is the core of the fix.if. With the success-side side effects (IncArticlesDownloaded/UpdateDownloadProgress) moved below the error check, thevar err error/ splitif err == nil/if err != nilblocks are no longer needed. The unreachable-segment error return is unchanged.Behavior change