fix(importer): fix context cancellation propagation to prevent stuck imports - #172
Merged
Merged
Conversation
…imports Fixes several issues where the import process could get stuck because context cancellation wasn't properly propagated: - Fix double-unlock panic bug in Stop() method - Add ctx.Done() checks in UsenetFile.Read() with timeout for reader creation - Add context checks before expensive operations in RAR and 7zip processors - Add context parameter to AddToQueue() and update all callers - Add context parameter to createNzbFileAndPrepareItem() and isFileAlreadyInQueue() - Replace context.Background() with proper service context in logging calls - Fix notifyRcloneVFS to derive timeout from parent context These changes ensure that when an import is cancelled, the cancellation properly propagates through all operations including network reads, archive analysis, and database operations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
Summary
Stop()method that caused crashes on service shutdownctx.Done()checks inUsenetFile.Read()with timeout for reader creation to prevent network hangsAddToQueue()and update all API handler callerscreateNzbFileAndPrepareItem()andisFileAlreadyInQueue()context.Background()with proper service context in logging callsnotifyRcloneVFSto derive timeout from parent context for proper cancellation propagationTest plan
go build ./...to verify compilationgo test ./internal/importer/...to verify existing tests pass🤖 Generated with Claude Code