Skip to content

Fix pending_completion stuck for stopped downloads deleted locally#272

Merged
nitrobass24 merged 1 commit intodevelopfrom
fix/pending-completion-stuck
Mar 13, 2026
Merged

Fix pending_completion stuck for stopped downloads deleted locally#272
nitrobass24 merged 1 commit intodevelopfrom
fix/pending-completion-stuck

Conversation

@nitrobass24
Copy link
Owner

@nitrobass24 nitrobass24 commented Mar 13, 2026

Summary

  • Fix pending_completion never clearing when a stopped download's local files are deleted with auto_delete_remote enabled
  • Adds early exit: when file is DEFAULT with local_size=None, clear from pending_completion since there's nothing left to track
  • Stops ActiveScanner from polling non-existent paths indefinitely

Root Cause

When an LFTP job disappears (stop or completion), the file enters pending_completion. Exit conditions only check for terminal states (DOWNLOADED, DELETED, etc.). But with auto_delete_remote=True and remote still present, the model builder skips persist authority, leaving the file in DEFAULT — which wasn't an exit condition. Result: ActiveScanner polls forever.

Test plan

  • Stop a downloading file, then delete its local files — verify spinner clears and ActiveScanner stops polling
  • Verify normal download completion still works (file transitions through DOWNLOADED → EXTRACTED etc.)
  • Verify with both staging enabled and disabled

Fixes #271

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed handling of locally-deleted files by adding validation checks to prevent errors when the system attempts to process or move files that have been deleted locally but remain in the tracking system.

When a stopped download's local files are deleted and auto_delete_remote
is enabled, the model builder skips persist authority (to allow
re-download), leaving the file in DEFAULT state. Since DEFAULT was not
a pending_completion exit condition, the ActiveScanner polled the
non-existent path indefinitely.

Add an early exit: clear pending_completion when a file is DEFAULT with
local_size=None, meaning local files are gone and nothing remains to
track.

Fixes #271

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c1d9aa47-01fc-495d-8467-e9e27b412b40

📥 Commits

Reviewing files that changed from the base of the PR and between 394482f and 3452db2.

📒 Files selected for processing (1)
  • src/python/controller/controller.py

📝 Walkthrough

Walkthrough

Adds a guard condition in __update_model to discard pending completion entries when a file is in DEFAULT state with no local size, preventing the ActiveScanner from polling non-existent locally-deleted files indefinitely.

Changes

Cohort / File(s) Summary
Pending Completion Cleanup
src/python/controller/controller.py
Added early exit guard in __update_model to discard pending_completion entries for files in DEFAULT state with no local size, preventing infinite polling of deleted local files.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • #208: Modifies __update_model's pending_completion cleanup logic in the same file to determine when entries should be discarded.
  • #82: Modifies __update_model's deletion and cleanup control flow to handle locally-deleted and staged files more correctly.

Suggested labels

bug

Poem

🐰 A spinner that spun round and round,
Polling paths with a mournful sound,
But now with a guard, so crisp and clean,
Deleted files fade from the scene,
No more forever, the fix is done! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary bug fix: addressing pending_completion getting stuck for stopped downloads with locally deleted files.
Linked Issues check ✅ Passed The code changes implement the exact fix specified in issue #271: adding an early exit condition to clear pending_completion when a file is DEFAULT with local_size=None.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the pending_completion stuck issue; no extraneous modifications or refactoring detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/pending-completion-stuck
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nitrobass24 nitrobass24 merged commit 28ee847 into develop Mar 13, 2026
9 checks passed
@nitrobass24 nitrobass24 deleted the fix/pending-completion-stuck branch March 13, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant