Repository navigation
[Bug] Fix remove_orphans deleting active downloads (#322) - #385
Merged
Merged
Conversation
- compare the full and normal queue by item id instead of whole records; sizeleft/timeleft of an active download change between the two fetches, so any progressing download was flagged as an orphan and deleted (ManiMatter#322) - regression test
lolimmlost
requested review from
Dark3clipse,
ManiMatter,
Sportarr,
jrhager84 and
lolimmlost
September 24, 2026 15:06
lolimmlost
approved these changes
Sep 24, 2026
lolimmlost
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed and tested locally. LGTM.
The root cause matches the analysis in #322: the full and normal queue fetches are separate requests, so progress fields (sizeleft, timeleft, estimatedCompletionTime) on an active download differ between them and the whole-record not in check flags it as an orphan. Comparing by queue item id is the right fix, since the *arr queue id is derived from the download and the media item and is stable across back-to-back fetches.
Verified:
- Full test suite passes (293 passed).
- The new regression test fails against current
dev(1 failed) and passes with the fix, so it actually covers the bug. - This was the only place in
src/doing a whole-record queue comparison, so there are no other instances of the same pattern. - If an item were ever missing
id,NonematchesNoneand it is not treated as an orphan, which fails safe (no deletion).
Nit (non-blocking): there are 3 blank lines before the new test in tests/utils/test_queue_manager.py; PEP 8 / ruff E303 wants 2.
Owner
|
@lolimmlost feel free to directly merge any PRs you approve. Full trust :) |
1 task
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.
Fixes #322.
get_queue_items("orphans")computed orphans as[fq for fq in full_queue if fq not in normal_queue], comparing whole records. The two fetches are separate requests after aRefreshMonitoredDownloads, sosizeleft/timeleft/estimatedCompletionTimeof an actively downloading item differ between them. The record comparison then fails and the download is treated as an orphan and removed (without blocklist, sinceRemoveOrphans.blocklist = False). Paused and stalled items never change between the fetches, which is why only healthy downloads were hit.Change: compare by queue item
idinstead of by record.src/utils/queue_manager.py: build a set of ids from the normal queue and keep full-queue items whose id is not in ittests/utils/test_queue_manager.py: regression test where the same item has a differentsizeleftin the two fetches; fails on the old code, passes on the newFull suite: 293 passed.
Verified on my Radarr/Sonarr + qBittorrent stack: the old image deleted three actively downloading remuxes over two days; the patched image ran three 5-minute cycles against a download progressing at ~3 MB/s with no removal.