1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-06 13:09:50 +00:00

Clean up the ETA logic a bit and make sure it works for restarted transfers.

This commit is contained in:
Dag-Erling Smørgrav 2003-03-11 08:21:51 +00:00
parent 1bbb80b674
commit 29568c0191
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=112083

View File

@ -125,16 +125,17 @@ struct xferstat {
static void
stat_eta(struct xferstat *xs)
{
long elapsed, remaining;
long elapsed, received, expected, eta;
elapsed = xs->last.tv_sec - xs->start.tv_sec;
remaining = ((xs->size * elapsed) / xs->rcvd) - elapsed;
if (remaining > 3600) {
fprintf(stderr, "%02ld:", remaining / 3600);
remaining %= 3600;
received = xs->rcvd - xs->offset;
expected = xs->size - xs->rcvd;
eta = (elapsed * expected) / received;
if (eta > 3600) {
fprintf(stderr, "%02ld:", eta / 3600);
eta %= 3600;
}
fprintf(stderr, "%02ld:%02ld",
remaining / 60, remaining % 60);
fprintf(stderr, "%02ld:%02ld", eta / 60, eta % 60);
}
/*