summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2011-02-10 22:35:52 (GMT)
committer Denys Vlasenko <vda.linux@googlemail.com>2011-02-10 22:35:52 (GMT)
commit838d4bb0cd0805e1671073627d86baf100af021b (patch)
tree5d1fcba7e3f5e301dd418d9f7f60aa69549a26fb
parentf836f01cc3eb39e5e4c7186f50b456b57fae2010 (diff)
downloadbusybox-838d4bb0cd0805e1671073627d86baf100af021b.tar.gz
busybox-838d4bb0cd0805e1671073627d86baf100af021b.tar.bz2
progress meter: display >999 hours ETA correctly
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--libbb/progress.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libbb/progress.c b/libbb/progress.c
index a490b83..3999e0f 100644
--- a/libbb/progress.c
+++ b/libbb/progress.c
@@ -156,7 +156,7 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p,
kiloscale++;
}
/* see http://en.wikipedia.org/wiki/Tera */
- fprintf(stderr, "%6u%c ", (unsigned)beg_and_transferred, " kMGTPEZY"[kiloscale]);
+ fprintf(stderr, "%6u%c", (unsigned)beg_and_transferred, " kMGTPEZY"[kiloscale]);
#define beg_and_transferred dont_use_beg_and_transferred_below()
if (transferred != p->lastsize) {
@@ -173,9 +173,9 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p,
elapsed -= p->start_sec; /* now it's "elapsed since start" */
if (since_last_update >= STALLTIME) {
- fprintf(stderr, " - stalled -");
+ fprintf(stderr, " - stalled -");
} else if (!totalsize || !transferred || (int)elapsed <= 0) {
- fprintf(stderr, "--:--:-- ETA");
+ fprintf(stderr, " --:--:-- ETA");
} else {
unsigned eta, secs, hours;
@@ -188,8 +188,10 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p,
* totalsize * elapsed / transferred - elapsed
*/
eta = totalsize * elapsed / transferred - elapsed;
+ if (eta >= 1000*60*60)
+ eta = 1000*60*60 - 1;
secs = eta % 3600;
hours = eta / 3600;
- fprintf(stderr, "%02u:%02u:%02u ETA", hours, secs / 60, secs % 60);
+ fprintf(stderr, "%3u:%02u:%02u ETA", hours, secs / 60, secs % 60);
}
}