Skip to content

Commit 92242f8

Browse files
committed
fix: [#1543] Remove peerless torrents when it's enabled in the tracker policy
There were not being removed when stats was enabled becuase the tracker was counting downloads only from the active swarms. Now the API exposed metric (global downldoads) is not taken from the in-memory data structrure unless stats persistence is disabled. In that case, the global total would be per session (since the tracker started), and reset when the tracker restarts.
1 parent 43c7179 commit 92242f8

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

packages/torrent-repository/src/swarm.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,7 @@ impl Swarm {
201201
/// Returns true if the swarm should be removed according to the retention
202202
/// policy.
203203
fn should_be_removed(&self, policy: &TrackerPolicy) -> bool {
204-
// If the policy is to remove peerless torrents and the swarm is empty (no peers),
205-
(policy.remove_peerless_torrents && self.is_empty())
206-
// but not when the policy is to persist torrent stats and the
207-
// torrent has been downloaded at least once.
208-
// (because the only way to store the counter is to keep the swarm in memory.
209-
// See https://github.com/torrust/torrust-tracker/issues/1502)
210-
&& !(policy.persistent_torrent_completed_stat && self.metadata().downloaded > 0)
204+
policy.remove_peerless_torrents && self.is_empty()
211205
}
212206

213207
fn update_metadata_on_insert(&mut self, added_peer: &Arc<PeerAnnouncement>) {

0 commit comments

Comments
 (0)