fix(daemon): reject the row a blacklisted add left behind
Closes #24 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+12
@@ -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"
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user