Revert the previous delta and apply a better fix which corrects
a check on the final snprintf and reduces duplicated code. Submitted by: brian
This commit is contained in:
parent
1e670ee4e8
commit
ad6c0a3768
@ -670,22 +670,16 @@ progressmeter(flag)
|
||||
if (bytes <= 0 || elapsed <= 0.0 || cursize > filesize) {
|
||||
n = snprintf(buf + len, sizeof(buf) - len,
|
||||
" --:-- ETA");
|
||||
if (n > 0 && n < sizeof(buf) - len)
|
||||
len += n;
|
||||
} else if (wait.tv_sec >= STALLTIME) {
|
||||
n = snprintf(buf + len, sizeof(buf) - len,
|
||||
" - stalled -");
|
||||
if (n > 0 && n < sizeof(buf) - len)
|
||||
len += n;
|
||||
} else {
|
||||
remaining =
|
||||
((filesize - restart_point) / (bytes / elapsed) - elapsed);
|
||||
if (remaining >= 100 * SECSPERHOUR) {
|
||||
if (remaining >= 100 * SECSPERHOUR)
|
||||
n = snprintf(buf + len, sizeof(buf) - len,
|
||||
" --:-- ETA");
|
||||
if (n > 0 && n < sizeof(buf) - len)
|
||||
len += n;
|
||||
} else {
|
||||
else {
|
||||
i = remaining / SECSPERHOUR;
|
||||
if (i)
|
||||
n = snprintf(buf + len, sizeof(buf) - len,
|
||||
@ -696,10 +690,12 @@ progressmeter(flag)
|
||||
if (n > 0 && n < sizeof(buf) - len)
|
||||
len += n;
|
||||
i = remaining % SECSPERHOUR;
|
||||
len += snprintf(buf + len, sizeof(buf) - len,
|
||||
n = snprintf(buf + len, sizeof(buf) - len,
|
||||
"%02d:%02d ETA", i / 60, i % 60);
|
||||
}
|
||||
}
|
||||
if (n > 0 && n < sizeof(buf) - len)
|
||||
len += n;
|
||||
(void)write(STDOUT_FILENO, buf, len);
|
||||
|
||||
if (flag == -1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user