Skip to content

make orphan recovery idempotent - #32

Merged
JeremiahM37 merged 2 commits into
JeremiahM37:mainfrom
vedhavyas:fix/orphan-dedup
Aug 24, 2026
Merged

make orphan recovery idempotent#32
JeremiahM37 merged 2 commits into
JeremiahM37:mainfrom
vedhavyas:fix/orphan-dedup

Conversation

@vedhavyas

Copy link
Copy Markdown
Contributor

Orphan recovery runs at startup and again whenever the monitor fires run_orphan_recovery, and it minted a fresh job id per torrent on every pass. So each run left another duplicate row, and for an in-progress torrent it also started a second watcher goroutine on the same hash, leaving both racing to import it.

This reuses the row already tracking a torrent, and takes a per-torrent claim in watchGameTorrent so only one watcher polls a given download. The claim lives in the watcher rather than the recovery loop so every caller is covered.

vedhavyas and others added 2 commits August 23, 2026 16:42
Recovery runs at startup and again on the monitor's run_orphan_recovery
command. It minted a job id per torrent per pass, so every run added a
duplicate row, and for an in-progress torrent it also started another
watcher goroutine on the same hash, leaving rivals racing to import it.

Reuse the row already tracking a torrent, and take a per-torrent claim in
watchGameTorrent so only one watcher polls a given download.
Reusing the row is right, but Set rewrites the whole row, and under a
source-preserving import finishTorrent deliberately leaves the torrent
seeding. So a game already in the library is still in the category on the
next pass, and recovery rewrote its completed row to
completed_unorganized -- which is the status that draws the Organize
button, on a game that is already organized. Pressing it imports it twice.

Skip the torrent when the row it belongs to is already completed, matching
the rule organizeGame's retry loop follows: completed is terminal and
nothing may overwrite it.
@JeremiahM37
JeremiahM37 merged commit b31713a into JeremiahM37:main Aug 24, 2026
3 checks passed
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.

2 participants