Merge pull request #104 from ikatson/better-eta

Fix ETA computation - fixes #92
This commit is contained in:
Igor Katson 2024-03-29 14:07:14 +00:00 committed by GitHub
commit 8e77f20a5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -248,10 +248,8 @@ impl TorrentStateLive {
let stats = state.stats_snapshot(); let stats = state.stats_snapshot();
let fetched = stats.fetched_bytes; let fetched = stats.fetched_bytes;
let needed = state.initially_needed(); let needed = state.initially_needed();
// fetched can be too high in theory, so for safety make sure that it doesn't wrap around u64. // TODO: this is too coarse.
let remaining = needed let remaining = needed - stats.downloaded_and_checked_bytes;
.wrapping_sub(fetched)
.min(needed - stats.downloaded_and_checked_bytes);
state state
.down_speed_estimator .down_speed_estimator
.add_snapshot(fetched, Some(remaining), now); .add_snapshot(fetched, Some(remaining), now);