fix(core): stop the size floor condemning a download
ci / web (push) Successful in 1m1s
ci / rust (push) Successful in 2m23s
e2e / e2e (push) Failing after 3m20s

The floor is a selection filter (§5.5): it keeps the ranking from picking
mud while better candidates are still on the table. Once a release is
grabbed there is nothing left to choose between, so a hard fail at import
condemns a file already on disk and blacklists the release under §5.7 —
over a number the indexer gave before the grab. Size is not post-download
evidence either; §5.6 gives ffprobe audio, HDR, codec and duration.

It bit packs hardest. Pre-grab measures a pack by its total over the
season length; import measures each file on its own, so one short episode
condemned the whole release and reopened the season. And §6.3 outlasts the
fix: a blacklisted release stays rejected however the operator later sets
allow_below_floor, with no delete path.

Post-download the floor now waives instead, whatever the overrides say.
The file imports and carries a waiver naming the floor it missed.
This commit is contained in:
Miguel Palhas
2026-08-26 18:34:57 +01:00
parent d3613c6081
commit 58ad90951c
2 changed files with 118 additions and 1 deletions
+60
View File
@@ -1980,6 +1980,18 @@ mod tests {
]
}"#;
/// The same file, one gigabyte instead of ten: under the 2160p floor.
/// A pack accepted pre-grab on its per-episode average carries episodes
/// like this whenever one runs short.
const TV_THIN_PROBE: &str = r#"{
"format": {"format_name": "matroska,webm", "duration": "3300.0", "size": "1073741824"},
"streams": [
{"codec_type": "video", "codec_name": "hevc", "width": 3840, "height": 1600,
"color_transfer": "smpte2084"},
{"codec_type": "audio", "codec_name": "eac3", "tags": {"language": "eng"}}
]
}"#;
const PACK_RELEASE_NAME: &str = "Fallout.S01.2160p.WEB-DL.DDP5.1.Atmos";
struct TvHarness {
@@ -2193,6 +2205,54 @@ mod tests {
assert_eq!(grab_state, "imported");
}
/// §5.5's floor is a selection filter, so it condemns nothing after the
/// download. A pack whose episodes come in under the band imports and
/// records the waiver: blacklisting it would throw away a file already
/// on disk over a number that was on the release before the grab, and
/// §6.3 would then outlast any override the operator later writes.
#[tokio::test]
async fn a_pack_under_the_floor_imports_with_a_waiver_rather_than_blacklisting() {
let h = tv_harness(TV_THIN_PROBE).await;
h.action.tick(&h.database).await.unwrap();
let blacklisted: i64 = sqlx::query_scalar("SELECT count(*) FROM blacklist")
.fetch_one(h.database.pool())
.await
.unwrap();
assert_eq!(blacklisted, 0, "the floor blacklists nothing post-download");
let waivers: Vec<Option<String>> =
sqlx::query_scalar("SELECT waiver FROM media_files ORDER BY path")
.fetch_all(h.database.pool())
.await
.unwrap();
assert_eq!(
waivers,
vec![
Some(r#"{"rule":"size"}"#.to_owned()),
Some(r#"{"rule":"size"}"#.to_owned())
],
"§5.7: import it, record the waiver, surface it"
);
let states: Vec<(String, bool)> =
sqlx::query_as("SELECT state, wanted FROM episodes ORDER BY number")
.fetch_all(h.database.pool())
.await
.unwrap();
assert_eq!(
states,
vec![
("available".to_owned(), true),
("available".to_owned(), true)
]
);
let grab_state: String = sqlx::query_scalar("SELECT state FROM grabs")
.fetch_one(h.database.pool())
.await
.unwrap();
assert_eq!(grab_state, "imported");
}
/// The third acceptance case, import side: a pack whose file hard-fails
/// blacklists that release and reopens the episodes — it does not
/// blacklist or block the season.