Commit 34c159a
committed
refactor: [torrust#1495] update method Swarm::meets_retaining_policy
Changed from:
```
/// Returns true if the torrents meets the retention policy, meaning that
/// it should be kept in the tracker.
pub fn meets_retaining_policy(&self, policy: &TrackerPolicy) -> bool {
if policy.persistent_torrent_completed_stat && self.metadata().downloaded > 0 {
return true;
}
if policy.remove_peerless_torrents && self.is_empty() {
return false;
}
true
}
```
To:
```
pub fn meets_retaining_policy(&self, policy: &TrackerPolicy) -> bool {
!(policy.remove_peerless_torrents && self.is_empty())
}
```
I think the first condition was introduced to avoid loosing the number of
downloads we¡hen the torrent is removed becuase there are no peers.
Now, we load that number from database when the torrent is added again
after removing it from the tracker.1 parent 0f4596e commit 34c159a
1 file changed
+27
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
| 193 | + | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
| 197 | + | |
207 | 198 | | |
208 | 199 | | |
209 | 200 | | |
| |||
214 | 205 | | |
215 | 206 | | |
216 | 207 | | |
| 208 | + | |
217 | 209 | | |
218 | 210 | | |
219 | 211 | | |
| |||
384 | 376 | | |
385 | 377 | | |
386 | 378 | | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
387 | 403 | | |
388 | 404 | | |
389 | 405 | | |
| |||
0 commit comments