From a37bb6652e236da776232dc8e3958813bd126383 Mon Sep 17 00:00:00 2001 From: Roardom Date: Fri, 14 Jun 2024 17:54:05 +0000 Subject: [PATCH] add: torrent soft deletion support https://github.com/HDInnovations/UNIT3D-Community-Edition/pull/3927 --- src/scheduler/torrent_update.rs | 12 ------------ src/tracker/torrent.rs | 2 ++ src/tracker/torrent/infohash2id.rs | 2 ++ 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/scheduler/torrent_update.rs b/src/scheduler/torrent_update.rs index eb95c0c..1da3998 100644 --- a/src/scheduler/torrent_update.rs +++ b/src/scheduler/torrent_update.rs @@ -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 } } diff --git a/src/tracker/torrent.rs b/src/tracker/torrent.rs index 91b4c2a..a5e2af6 100644 --- a/src/tracker/torrent.rs +++ b/src/tracker/torrent.rs @@ -76,6 +76,8 @@ impl Map { 0 as `is_deleted: bool` FROM torrents + WHERE + torrents.deleted_at IS NULL "# ) .fetch_all(db) diff --git a/src/tracker/torrent/infohash2id.rs b/src/tracker/torrent/infohash2id.rs index 737cbeb..901f60a 100644 --- a/src/tracker/torrent/infohash2id.rs +++ b/src/tracker/torrent/infohash2id.rs @@ -36,6 +36,8 @@ impl Map { torrents.info_hash as `info_hash: InfoHash` FROM torrents + WHERE + torrents.deleted_at IS NULL "# ) .fetch_all(db)