Skip to content

Commit

Permalink
add: torrent soft deletion support
Browse files Browse the repository at this point in the history
  • Loading branch information
Roardom committed Jun 14, 2024
1 parent 50cdd26 commit a37bb66
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
12 changes: 0 additions & 12 deletions src/scheduler/torrent_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,6 @@ impl Queue {
.await
.map(|result| result.rows_affected());

if rows_affected_res.is_ok() {
// When torrent records are upserted after they have been deleted
// since the last flush interval, the record gets unintentionally
// re-inserted. So, we need to delete it again. All re-inserted
// records would have an info_hash of 20 bytes worth of binary 0.
let _ = sqlx::query!(
r#"DELETE from torrents WHERE info_hash = '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'"#
)
.execute(db)
.await;
}

rows_affected_res
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/tracker/torrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ impl Map {
0 as `is_deleted: bool`
FROM
torrents
WHERE
torrents.deleted_at IS NULL
"#
)
.fetch_all(db)
Expand Down
2 changes: 2 additions & 0 deletions src/tracker/torrent/infohash2id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ impl Map {
torrents.info_hash as `info_hash: InfoHash`
FROM
torrents
WHERE
torrents.deleted_at IS NULL
"#
)
.fetch_all(db)
Expand Down

0 comments on commit a37bb66

Please sign in to comment.