diff --git a/src/announce.rs b/src/announce.rs index 27dfc6c..2f644e9 100644 --- a/src/announce.rs +++ b/src/announce.rs @@ -358,8 +358,9 @@ pub async fn announce( _ => (), } - // Make sure user isn't leeching more torrents than their group allows + // Make sure user isn't leeching more torrents than their group allows unless they are a lifetime user let has_hit_download_slot_limit = queries.left > 0 + && !user.is_lifetime && matches!(group.download_slots, Some(slots) if slots <= user.num_leeching); // Change of upload/download compared to previous announce @@ -663,6 +664,7 @@ pub async fn announce( .featured_torrents .read() .contains(&FeaturedTorrent { torrent_id }) + || user.is_donor { 0 } else { @@ -725,7 +727,7 @@ pub async fn announce( queries.downloaded, queries.left == 0, queries.event != Event::Stopped, - group.is_immune, + group.is_immune || user.is_donor, completed_at, ); diff --git a/src/scheduler/torrent_update.rs b/src/scheduler/torrent_update.rs index eb95c0c..a8a2188 100644 --- a/src/scheduler/torrent_update.rs +++ b/src/scheduler/torrent_update.rs @@ -155,6 +155,7 @@ 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 @@ -166,6 +167,7 @@ impl Queue { .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) diff --git a/src/tracker/user.rs b/src/tracker/user.rs index 35e16f9..328ebd4 100644 --- a/src/tracker/user.rs +++ b/src/tracker/user.rs @@ -36,7 +36,9 @@ impl Map { users.passkey as `passkey: Passkey`, users.can_download as `can_download: bool`, CAST(COALESCE(SUM(peers.seeder = 1 AND peers.active = 1 AND peers.visible = 1), 0) AS UNSIGNED) as `num_seeding: u32`, - CAST(COALESCE(SUM(peers.seeder = 0 AND peers.active = 1 AND peers.visible = 1), 0) AS UNSIGNED) as `num_leeching: u32` + CAST(COALESCE(SUM(peers.seeder = 0 AND peers.active = 1 AND peers.visible = 1), 0) AS UNSIGNED) as `num_leeching: u32`, + users.is_donor as `is_donor: bool`, + users.is_lifetime as `is_lifetime: bool` FROM users LEFT JOIN @@ -78,6 +80,8 @@ impl Map { can_download: user.can_download, num_seeding: user.num_seeding, num_leeching: user.num_leeching, + is_donor: user.is_donor, + is_lifetime: user.is_lifetime, }, ); @@ -140,6 +144,8 @@ pub struct User { pub can_download: bool, pub num_seeding: u32, pub num_leeching: u32, + pub is_donor: bool, + pub is_lifetime: bool, } #[derive(Clone, Deserialize, Hash)] @@ -150,6 +156,8 @@ pub struct APIInsertUser { pub can_download: bool, pub num_seeding: u32, pub num_leeching: u32, + pub is_donor: bool, + pub is_lifetime: bool, } #[derive(Clone, Deserialize, Hash)]