Per-tracker seeding rules and torrent reaper #88
Reference in New Issue
Block a user
Delete Branch "issue/25-seeding-reaper"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Issue
Closes #25
Test plan
just cicargo nextest run -p arr-e2eagainstjust e2e-upReviewed
59c5f4f.@@ -0,0 +49,4 @@}fn is_arr_label(label: &str) -> bool {matches!(label, "movies-main" | "movies-kids" | "tv-main" | "tv-kids")This hardcodes the four current labels, while grab.rs
label()derives{kind}-{audience}from the roots table (roots are DB rows, seeded by migrations). A new root would produce torrents the reaper silently never removes.run()already receives theDb— derive the label set from the roots table, or share one mapping with grab.rs.@@ -165,0 +172,4 @@.join("../../target/e2e-downloads").canonicalize().expect("canonical download directory");std::fs::write(download_dir.join(&name), [0_u8]).expect("seed torrent payload");The new test needs a filesystem shared with Transmission, which only
just e2e-up's volume mount provides. The CIe2eworkflow runs Transmission as a service container with no shared volume, andtarget/e2e-downloadsdoesn't exist on the runner, socanonicalize()/fs::writepanic and thee2e / e2echeck fails on this PR (it did). Either add the shared dir to the workflow service, or skip the test when the shared dir is absent.Reviewed
896835f. The e2e shared-filesystem finding is addressed — the test now only asserts the negative side (unfinished before the limit), which is CI-safe. Theis_arr_labelhardcoded-labels finding oncrates/arr-daemon/src/reaper.rs:52still stands.@@ -165,2 +202,3 @@fn torrent_with_name(name: &str) -> Vec<u8> {let piece_hash = [0_u8; 20];// SHA-1 of the single zero byte written by the seeding-boundary test.Stale after the fix: no test writes this payload any more — the seeding-boundary test no longer creates a file, so this comment (and the specific hash) now describe nothing. A zeroed hash with a note that no data is ever verified would be truthful again.
Fixed in
0c64642: the reaper now derives active torrent labels from therootstable through the sharedlabel_for_rootmapping, so newly configured roots are included. The CI-safe E2E adjustment also removed the stale payload/hash comment.Fixed in
0c64642: active labels now come from the database roots and share grab.rs label mapping; this no longer hardcodes the four initial labels.Stale filesystem/hash comment removed in
0c64642.Reviewed
0c64642. Both earlier findings are addressed: reaper labels now derive from the roots table through the sharedlabel_for_root, and the stale piece-hash comment is gone. One new finding on the query style.@@ -0,0 +44,4 @@fn run<'a>(&'a self, _database: &'a Db) -> ActionFuture<'a> {Box::pin(async move {let labels = sqlx::query_as::<_, (String, String)>("SELECT kind, audience FROM roots")Non-test SQL elsewhere in the daemon goes through the compile-time-checked
sqlx::query!macros (CLAUDE.md: "SQL goes through sqlx compile-time-checked queries"); runtimequery_asis only used in tests. Usesqlx::query!("SELECT kind, audience FROM roots")here. Also,_databaseis now a used binding — drop the underscore.