Repository navigation
fix: seeding cleanup removes a torrent shared by finished requests - #464
Merged
Merged
Conversation
#283) The cleanup job's shared-torrent check counted every non-deleted request on the torrent, so several finished requests (a series pack) kept it for each other forever. In the cleanup job, another request now keeps the torrent unless it is finished (audiobook available, ebook downloaded), recorded for the configured client, and done seeding by its own indexer's rule. When the torrent goes, the other requests' rows are marked removed too. Request deletion keeps today's rule: any other active request keeps the torrent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…port from it (#283) A library scan can mark an audiobook available while its organize is still copying. The seeding cleanup now lets such a sibling release the torrent only when its book record was completed by the organizer (with a file path) after the sibling's row took the torrent. Also tests a soft-deleted owner removing a torrent whose only active sibling is finished and done seeding. Co-Authored-By: Claude Opus 5.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.
Closes #283
What changed
src/lib/processors/cleanup-seeded-torrents.processor.ts): before removing a torrent, it now asksotherActiveRequestsSharingTorrent()for the other non-deleted requests on that torrent, with their type, status and download rows. Each of them keeps the torrent unlesssiblingKeepsTorrent()(src/lib/utils/shared-torrent.ts) finds it:availableor ebookdownloaded(FINISHED_REQUESTS, also the job's own candidate statuses);completedwith afilePath(only the organizer writes that, after the copy) andcompletedAtlater than its row for this torrent. A library scan can mark a requestavailablewhile the copy is still running, and a library match alone never passes;evaluateSeeding()with that row's indexer settings, on the same client answer). An unlimited or unconfigured indexer keeps it.deleteDownload, this request's row markedremoved(a soft-deleted request is hard-deleted, as before), and the other requests' rows markedremovedin oneupdateMany. A row RMAB did not add (a series pack the 2nd and 3rd request found already in the client) never reaches this point on its own, so this is the only way its row learns the torrent is gone.req-x (audiobook downloading),req-y (still seeding for Tracker: ratio --/--, time 40/600 min)).otherActiveRequestsUsingTorrent()is untouched and still keeps the torrent for any other active request.documentation/admin-features/request-deletion.md(cleanup rule, Fixed Issues Fix broken matching feature on homepage #6), one known-limit line indocumentation/phase3/download-clients.md, the cleanup steps indocumentation/phase3/file-organization.md.Why
Three requests shared one series-pack torrent, all
available, seeding requirement met. The cleanup's shared-torrent check counted every non-deleted request on the torrent, so each finished request kept it for the other two, every run. The issue's log shows the same three requests skipping each other.Evidence
tests/processors/cleanup-seeded-torrents.shared.test.tsruns the real processor with afindManythat answers the page query and the shared-torrent query from fixture requests:deleteDownload, all three rowsremoved, no errors;addedByRmab: false) and the owner processed last: one delete, all three rowsremoved;removedthrough the probe, no errors;downloading,processing, audiobookdownloadedorfailed: nothing removed;removed, the owner hard-deleted;tests/services/request-delete.seeding.test.ts: new case, a finished, done-seeding request still keeps the torrent when another request is deleted.main's processor andshared-torrent.ts(ece1559) and the two test files: 4 failed, 30 passed (every case that expects the removal:deleteDownloadcalled 0 times). On this branch: 34/34.Checks
vitest relatedonshared-torrent.tsand the processor, the new test file included): PASS, 84 files, 1089/1089tsc --noEmitclean; ESLint on the touched code and test files: no new findings compared with main)242-torrent-seeding,242-delete-guardwithmedia-bind, one stack each): PASS,242-torrent-seeding1/1,242-delete-guard12/12. The import check only changes the shared-torrent decision, which the unit tests above coverRisk and rollback
deleteDownload(id, true), as for a torrent only one request uses). This includes a soft-deleted request whose active siblings all meet that rule: it now removes the torrent and is hard-deleted, where before one finished sibling kept it. A finished request has been imported or matched in the library, so removal is the same as for a torrent one request uses: a hard link or a separate copy in the library survives it, and a layout where the library path is the download path does not (unchanged from today).knownNotOwned(),resolveOwnership()) still run first on the row that removes it. A torrent RMAB did not add for that row is kept, exactly as before.availableand ebookdownloadedkeeps the torrent, so a request downloading, processing, waiting for import or failed keeps its files. An audiobook sibling also needs RMAB's own import from this torrent to be complete, so one a library scan markedavailablemid-copy keeps it, and one only matched in the library keeps it as on main. A torrent only one request uses is decided as before.removedstayremoved; nothing else is rewritten.removedare correct either way.Release note
🤖 Generated with Claude Code