Repository navigation
fix(torrent): forget a finished task's sidecar when its output was relative - #617
Merged
Merged
Conversation
…lative Every v1 torrent `ketch <url>` downloaded into the current directory left its .ketch-<hash>-<task> sidecar (checkpoint, ownership journal, boundary pieces) behind, warning "Kept the bookkeeping … Ownership journal belongs to another task". The journal's binding read the store's constructor parameter, which shadows the resolved output property inside the lazy initializer, so a store reopened through a relative path computed another binding than the engine's, which always passes an absolute one. The binding now names the resolved output. Journals written before, bound to the output as given, still load and are rebound by the next compaction.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
Contributor
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.
Found while downloading public torrents (Debian netinst, Internet Archive's Big Buck Bunny, WebTorrent's Sintel) with
ketch <url>into the current directory. Every v1 torrent ended with:and left its hidden
.ketch-<hash>-<task>/sidecar (checkpoint,ownership, and.piecefiles for boundary pieces of skipped files) in the download folder. The CLI removes the task once it finishes precisely so this sidecar doesn't clutter the folder. With an absolute destination it was cleaned up; with a relative one (the default,./) it never was. v2 and hybrid torrents were fine.Why
TorrentPieceStoreresolves itsoutputparameter into the propertyprivate val output = absolute(output). But inside thejournal by lazy { … }initializer, a bareoutputnames the constructor parameter, which shadows the property there. So the journal was bound to the path as given:TorrentDownloadSource.forget/cleanupreopen the store withcontext.outputPath, which is relative for a relative destination. The binding they computed (output: payload.bin) never matched the journal, the check threw, and the sidecar was kept.What changes
this.output, with a comment on the shadowing).TorrentOwnershipJournaltakeslegacyBindings: journals written by earlier versions were bound to the output as given, which can differ from the resolved path when a folder in it is a symlink (Android's/sdcard, macOS's/tmp). They still load, and the next compaction rewrites them with the current binding, so existing tasks keep resuming.Verification
ketch <file>.torrentwith a relative destination on a local web-seed torrent: no warning, no sidecar left, payload hash matches. Before: the warning, plus the sidecar left behind. A multi-file torrent with one file selected also leaves only that file.TorrentCheckpointTest.forget_storeReopenedThroughAnotherSpellingOfItsOutput_removesTheSidecar(fails before the fix with the production error) andTorrentOwnershipJournalTest.legacyBindingLoadsAndCompactionRebindsIt../gradlew :library:torrent:jvmTestpasses.