diff --git a/.sqlx/query-d870deeac972fd856a304b61131829ed40a9e72fe57be4f407e132233d2820a1.json b/.sqlx/query-594d1391c0e9d8a0dded5a354e0dc438bfdbac096ef23b5c3b816afdc03684ae.json similarity index 77% rename from .sqlx/query-d870deeac972fd856a304b61131829ed40a9e72fe57be4f407e132233d2820a1.json rename to .sqlx/query-594d1391c0e9d8a0dded5a354e0dc438bfdbac096ef23b5c3b816afdc03684ae.json index 832140c..00e3633 100644 --- a/.sqlx/query-d870deeac972fd856a304b61131829ed40a9e72fe57be4f407e132233d2820a1.json +++ b/.sqlx/query-594d1391c0e9d8a0dded5a354e0dc438bfdbac096ef23b5c3b816afdc03684ae.json @@ -1,6 +1,6 @@ { "db_name": "SQLite", - "query": "SELECT g.target_id AS \"season_id!: i64\",\n r.name AS \"name!: String\",\n g.infohash AS \"infohash!: String\",\n g.failed_at,\n g.grabbed_at AS \"grabbed_at!: String\"\n FROM grabs g\n JOIN releases r ON r.id = g.release_id\n JOIN seasons s ON s.id = g.target_id\n WHERE g.target_kind = 'season'\n AND g.state = 'failed'\n AND s.series_id = ?\n AND EXISTS (\n SELECT 1 FROM episodes e\n WHERE e.season_id = s.id AND e.wanted\n AND NOT EXISTS (\n SELECT 1 FROM media_files f\n WHERE f.owner_kind = 'episode' AND f.owner_id = e.id\n )\n )\n -- A later attempt owns the headline while it is still in\n -- flight. Keep the failed grab recorded; it is simply no\n -- longer the current explanation for the gap.\n AND NOT EXISTS (\n SELECT 1 FROM grabs newer\n WHERE newer.target_kind = 'season'\n AND newer.target_id = g.target_id\n AND newer.state != 'failed'\n AND (newer.grabbed_at > coalesce(g.failed_at, g.grabbed_at)\n OR (newer.grabbed_at = coalesce(g.failed_at, g.grabbed_at)\n AND newer.id > g.id))\n )\n ORDER BY coalesce(g.failed_at, g.grabbed_at), g.id", + "query": "SELECT g.target_id AS \"season_id!: i64\",\n r.name AS \"name!: String\",\n g.infohash AS \"infohash!: String\",\n g.failed_at,\n g.grabbed_at AS \"grabbed_at!: String\"\n FROM grabs g\n JOIN releases r ON r.id = g.release_id\n JOIN seasons s ON s.id = g.target_id\n WHERE g.target_kind = 'season'\n AND g.state = 'failed'\n AND s.series_id = ?\n AND EXISTS (\n SELECT 1 FROM episodes e\n WHERE e.season_id = s.id AND e.wanted\n AND NOT EXISTS (\n SELECT 1 FROM media_files f\n WHERE f.owner_kind = 'episode' AND f.owner_id = e.id\n )\n )\n -- A later attempt owns the headline while it is still in\n -- flight. Keep the failed grab recorded; it is simply no\n -- longer the current explanation for the gap.\n AND NOT EXISTS (\n SELECT 1 FROM grabs newer\n WHERE newer.target_kind = 'season'\n AND newer.target_id = g.target_id\n -- 'vanished' is not a live attempt either: the\n -- torrent left Transmission, so letting it take the\n -- headline would leave the season saying nothing at\n -- all about a gap that still exists.\n AND newer.state NOT IN ('failed', 'vanished')\n AND (newer.grabbed_at > coalesce(g.failed_at, g.grabbed_at)\n OR (newer.grabbed_at = coalesce(g.failed_at, g.grabbed_at)\n AND newer.id > g.id))\n )\n ORDER BY coalesce(g.failed_at, g.grabbed_at), g.id", "describe": { "columns": [ { @@ -70,5 +70,5 @@ false ] }, - "hash": "d870deeac972fd856a304b61131829ed40a9e72fe57be4f407e132233d2820a1" + "hash": "594d1391c0e9d8a0dded5a354e0dc438bfdbac096ef23b5c3b816afdc03684ae" } diff --git a/crates/arr-api/src/series.rs b/crates/arr-api/src/series.rs index becf180..6ea2f87 100644 --- a/crates/arr-api/src/series.rs +++ b/crates/arr-api/src/series.rs @@ -1705,7 +1705,11 @@ async fn season_import_failures( SELECT 1 FROM grabs newer WHERE newer.target_kind = 'season' AND newer.target_id = g.target_id - AND newer.state != 'failed' + -- 'vanished' is not a live attempt either: the + -- torrent left Transmission, so letting it take the + -- headline would leave the season saying nothing at + -- all about a gap that still exists. + AND newer.state NOT IN ('failed', 'vanished') AND (newer.grabbed_at > coalesce(g.failed_at, g.grabbed_at) OR (newer.grabbed_at = coalesce(g.failed_at, g.grabbed_at) AND newer.id > g.id))