Skip to content

Commit 1766587

Browse files
committed
feat: [#1002] remove inactive peers always
even when `remove_peerless_torrents` is disabled. We should remove peer that haven't announce otherwise we are returning inactive peers to the clients. That does not affect keeping the torrents even if they don't have any peer.
1 parent bd5f4e8 commit 1766587

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/core/mod.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -778,18 +778,17 @@ impl Tracker {
778778
self.torrents.get_metrics()
779779
}
780780

781-
/// Remove inactive peers and (optionally) peerless torrents
781+
/// Remove inactive peers and (optionally) peerless torrents.
782782
///
783783
/// # Context: Tracker
784784
pub fn cleanup_torrents(&self) {
785-
// If we don't need to remove torrents we will use the faster iter
785+
let current_cutoff = CurrentClock::now_sub(&Duration::from_secs(u64::from(self.config.tracker_policy.max_peer_timeout)))
786+
.unwrap_or_default();
787+
788+
self.torrents.remove_inactive_peers(current_cutoff);
789+
786790
if self.config.tracker_policy.remove_peerless_torrents {
787791
self.torrents.remove_peerless_torrents(&self.config.tracker_policy);
788-
} else {
789-
let current_cutoff =
790-
CurrentClock::now_sub(&Duration::from_secs(u64::from(self.config.tracker_policy.max_peer_timeout)))
791-
.unwrap_or_default();
792-
self.torrents.remove_inactive_peers(current_cutoff);
793792
}
794793
}
795794

0 commit comments

Comments
 (0)