Skip to content

Commit 7ca51a7

Browse files
RoardomHDVinnie
andcommitted
add: custom schema changes
Add: - `torrents.deleted_at` - `users.is_donor` - `users.is_lifetime` Co-authored-by: HDVinnie <hdinnovations@protonmail.com>
1 parent 1bd830d commit 7ca51a7

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

src/announce.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,9 @@ pub async fn announce(
358358
_ => (),
359359
}
360360

361-
// Make sure user isn't leeching more torrents than their group allows
361+
// Make sure user isn't leeching more torrents than their group allows unless they are a lifetime user
362362
let has_hit_download_slot_limit = queries.left > 0
363+
&& !user.is_lifetime
363364
&& matches!(group.download_slots, Some(slots) if slots <= user.num_leeching);
364365

365366
// Change of upload/download compared to previous announce
@@ -662,6 +663,7 @@ pub async fn announce(
662663
.featured_torrents
663664
.read()
664665
.contains(&FeaturedTorrent { torrent_id })
666+
|| user.is_donor
665667
{
666668
0
667669
} else {
@@ -724,7 +726,7 @@ pub async fn announce(
724726
queries.downloaded,
725727
queries.left == 0,
726728
queries.event != Event::Stopped,
727-
group.is_immune,
729+
group.is_immune || user.is_donor,
728730
completed_at,
729731
);
730732

src/scheduler/torrent_update.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ impl Queue {
155155
.await
156156
.map(|result| result.rows_affected());
157157

158+
/*
158159
if rows_affected_res.is_ok() {
159160
// When torrent records are upserted after they have been deleted
160161
// since the last flush interval, the record gets unintentionally
@@ -166,6 +167,7 @@ impl Queue {
166167
.execute(db)
167168
.await;
168169
}
170+
*/
169171

170172
rows_affected_res
171173
}

src/tracker/torrent.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ impl Map {
7676
0 as `is_deleted: bool`
7777
FROM
7878
torrents
79+
WHERE
80+
torrents.deleted_at IS NULL
7981
"#
8082
)
8183
.fetch_all(db)

src/tracker/torrent/infohash2id.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ impl Map {
3636
torrents.info_hash as `info_hash: InfoHash`
3737
FROM
3838
torrents
39+
WHERE
40+
torrents.deleted_at IS NULL
3941
"#
4042
)
4143
.fetch_all(db)

src/tracker/user.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ impl Map {
3636
users.passkey as `passkey: Passkey`,
3737
users.can_download as `can_download: bool`,
3838
CAST(COALESCE(SUM(peers.seeder = 1 AND peers.active = 1 AND peers.visible = 1), 0) AS UNSIGNED) as `num_seeding: u32`,
39-
CAST(COALESCE(SUM(peers.seeder = 0 AND peers.active = 1 AND peers.visible = 1), 0) AS UNSIGNED) as `num_leeching: u32`
39+
CAST(COALESCE(SUM(peers.seeder = 0 AND peers.active = 1 AND peers.visible = 1), 0) AS UNSIGNED) as `num_leeching: u32`,
40+
users.is_donor as `is_donor: bool`,
41+
users.is_lifetime as `is_lifetime: bool`
4042
FROM
4143
users
4244
LEFT JOIN
@@ -78,6 +80,8 @@ impl Map {
7880
can_download: user.can_download,
7981
num_seeding: user.num_seeding,
8082
num_leeching: user.num_leeching,
83+
is_donor: user.is_donor,
84+
is_lifetime: user.is_lifetime,
8185
},
8286
);
8387

@@ -140,6 +144,8 @@ pub struct User {
140144
pub can_download: bool,
141145
pub num_seeding: u32,
142146
pub num_leeching: u32,
147+
pub is_donor: bool,
148+
pub is_lifetime: bool,
143149
}
144150

145151
#[derive(Clone, Deserialize, Hash)]
@@ -150,6 +156,8 @@ pub struct APIInsertUser {
150156
pub can_download: bool,
151157
pub num_seeding: u32,
152158
pub num_leeching: u32,
159+
pub is_donor: bool,
160+
pub is_lifetime: bool,
153161
}
154162

155163
#[derive(Clone, Deserialize, Hash)]

0 commit comments

Comments
 (0)