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:
co-authored by
Claude Opus 5
parent
f36e86ec66
commit
b2241364e3
+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
|
// Transmission has fetched it, so the same blacklisted torrent can
|
||||||
// reach here under a new name.
|
// reach here under a new name.
|
||||||
if blacklist.blocks_infohash(&infohash) {
|
if blacklist.blocks_infohash(&infohash) {
|
||||||
self.drop_blacklisted_torrent(database, movie, &winner.name, &added)
|
self.drop_blacklisted_torrent(database, movie, &winner, &added)
|
||||||
.await?;
|
.await?;
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
@@ -418,9 +418,10 @@ impl GrabAction {
|
|||||||
&self,
|
&self,
|
||||||
database: &Db,
|
database: &Db,
|
||||||
movie: &PendingMovie,
|
movie: &PendingMovie,
|
||||||
release_name: &str,
|
winner: &Eligible,
|
||||||
added: &arr_dl::AddedTorrent,
|
added: &arr_dl::AddedTorrent,
|
||||||
) -> Result<(), GrabError> {
|
) -> Result<(), GrabError> {
|
||||||
|
let release_name = &winner.name;
|
||||||
blacklist::add(
|
blacklist::add(
|
||||||
database.pool(),
|
database.pool(),
|
||||||
None,
|
None,
|
||||||
@@ -428,6 +429,17 @@ impl GrabAction {
|
|||||||
"blacklisted infohash under a new name",
|
"blacklisted infohash under a new name",
|
||||||
)
|
)
|
||||||
.await?;
|
.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 {
|
if added.was_duplicate {
|
||||||
// The earlier grab's torrent, still working off its seeding
|
// The earlier grab's torrent, still working off its seeding
|
||||||
// obligation (§7.3). Nothing here deletes a torrent.
|
// obligation (§7.3). Nothing here deletes a torrent.
|
||||||
@@ -1150,6 +1162,15 @@ mod tests {
|
|||||||
// Transmission again.
|
// Transmission again.
|
||||||
let blacklist = Blacklist::load(database.pool()).await.unwrap();
|
let blacklist = Blacklist::load(database.pool()).await.unwrap();
|
||||||
assert!(blacklist.blocks_name("Dune.Part.Two.2024.2160p.WEB-DL.DDP5.1.Atmos"));
|
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.
|
/// §6.3: `blocked` stops targeted search for a title.
|
||||||
|
|||||||
Reference in New Issue
Block a user