fix(daemon): reject the row a blacklisted add left behind
ci / web (pull_request) Successful in 26s
ci / rust (pull_request) Successful in 47s
e2e / e2e (pull_request) Successful in 48s

Closes #24

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Miguel Palhas
2026-08-22 23:40:09 +01:00
parent f36e86ec66
commit b2241364e3
2 changed files with 35 additions and 2 deletions
@@ -0,0 +1,12 @@
{
"db_name": "SQLite",
"query": "UPDATE releases SET verdict = 'rejected', rejected_rule = ? WHERE id = ?",
"describe": {
"columns": [],
"parameters": {
"Right": 2
},
"nullable": []
},
"hash": "8618f066558095607d224389ea16b901e1fd55c3e3b71d61433ddd9e2fa9bbf0"
}
+23 -2
View File
@@ -358,7 +358,7 @@ impl GrabAction {
// Transmission has fetched it, so the same blacklisted torrent can
// reach here under a new name.
if blacklist.blocks_infohash(&infohash) {
self.drop_blacklisted_torrent(database, movie, &winner.name, &added)
self.drop_blacklisted_torrent(database, movie, &winner, &added)
.await?;
return Ok(None);
}
@@ -418,9 +418,10 @@ impl GrabAction {
&self,
database: &Db,
movie: &PendingMovie,
release_name: &str,
winner: &Eligible,
added: &arr_dl::AddedTorrent,
) -> Result<(), GrabError> {
let release_name = &winner.name;
blacklist::add(
database.pool(),
None,
@@ -428,6 +429,17 @@ impl GrabAction {
"blacklisted infohash under a new name",
)
.await?;
// `store_release` classified this row before the infohash was known,
// so it still reads eligible. Correct it here rather than waiting for
// the next search to overwrite it: until then §9.3's manual view
// would keep offering a release this tick just refused.
sqlx::query!(
"UPDATE releases SET verdict = 'rejected', rejected_rule = ? WHERE id = ?",
blacklist::RULE,
winner.id
)
.execute(database.pool())
.await?;
if added.was_duplicate {
// The earlier grab's torrent, still working off its seeding
// obligation (§7.3). Nothing here deletes a torrent.
@@ -1150,6 +1162,15 @@ mod tests {
// Transmission again.
let blacklist = Blacklist::load(database.pool()).await.unwrap();
assert!(blacklist.blocks_name("Dune.Part.Two.2024.2160p.WEB-DL.DDP5.1.Atmos"));
// And the cached row stops reading eligible straight away, so §9.3's
// manual view never offers what this tick just refused.
let (verdict, rule): (String, Option<String>) =
sqlx::query_as("SELECT verdict, rejected_rule FROM releases WHERE guid = 'good'")
.fetch_one(database.pool())
.await
.unwrap();
assert_eq!(verdict, "rejected");
assert_eq!(rule.as_deref(), Some("blacklisted"));
}
/// §6.3: `blocked` stops targeted search for a title.