Tests: removing old and over-quota downloads #396

Closed
opened 2026-11-06 19:51:40 -08:00 by rays · 1 comment
Owner

retention.rs is at 59% of its lines with both suites together, and what is untested is the part that deletes files: run's age and quota passes (lines 79-97) and remove (104-119), which deletes the file, marks it reaped and counts the bytes freed. The pure choosers (aged, pick) have tests; nothing runs them against files and a database. A mistake here deletes someone's downloads.

Tests to add (cargo, against a scratch data directory):

  • a download older than max_age_days is deleted from disk, marked reaped, and its bytes counted; one newer is left
  • over max_total_gb, the oldest go first until under, and what the age pass took is not counted twice
  • a dry run deletes nothing and reports the same bytes
  • a file already gone is marked reaped without an error; one that cannot be deleted is warned about and left marked unreaped
  • entries are pruned past the cutoff only when not a dry run
  • kept and held items (a back catalogue's files are held, not counted as pending) are never candidates

Seen with the coverage of both suites merged line by line (cargo: sh scripts/coverage.sh, browser: sh scripts/coverage.sh api; reports in target/coverage/cargo, api and page; #390, #394), as of 2026-11-07. A test added here shows in Grafana's Coverage row at the next run.

retention.rs is at 59% of its lines with both suites together, and what is untested is the part that deletes files: `run`'s age and quota passes (lines 79-97) and `remove` (104-119), which deletes the file, marks it reaped and counts the bytes freed. The pure choosers (`aged`, `pick`) have tests; nothing runs them against files and a database. A mistake here deletes someone's downloads. Tests to add (cargo, against a scratch data directory): - a download older than `max_age_days` is deleted from disk, marked reaped, and its bytes counted; one newer is left - over `max_total_gb`, the oldest go first until under, and what the age pass took is not counted twice - a dry run deletes nothing and reports the same bytes - a file already gone is marked reaped without an error; one that cannot be deleted is warned about and left marked unreaped - entries are pruned past the cutoff only when not a dry run - kept and held items (a back catalogue's files are held, not counted as pending) are never candidates Seen with the coverage of both suites merged line by line (cargo: `sh scripts/coverage.sh`, browser: `sh scripts/coverage.sh api`; reports in target/coverage/cargo, api and page; #390, #394), as of 2026-11-07. A test added here shows in Grafana's Coverage row at the next run.
rays added the enhancement label 2026-11-06 19:51:40 -08:00
Author
Owner

Tests added in a92e81a (retention.rs): the age pass deletes, marks reaped, counts bytes and prunes entries, and a dry run does none of it but counts the same; over quota the oldest go first and the age pass's take is not counted twice; a missing file is reaped without an error and one that cannot be unlinked (/proc/version) is left unreaped with nothing counted; held items are never candidates. Pass on SQLite and Postgres. Kept (starred) items were already covered by query_never_offers_a_file_anyone_starred...

Tests added in a92e81a (retention.rs): the age pass deletes, marks reaped, counts bytes and prunes entries, and a dry run does none of it but counts the same; over quota the oldest go first and the age pass's take is not counted twice; a missing file is reaped without an error and one that cannot be unlinked (/proc/version) is left unreaped with nothing counted; held items are never candidates. Pass on SQLite and Postgres. Kept (starred) items were already covered by query_never_offers_a_file_anyone_starred...
rays closed this issue 2026-11-06 19:55:57 -08:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rays/ipx#396