If we've finished transferring a file, show the time taken; otherwise
authorMartin Pool <mbp@samba.org>
Fri, 15 Mar 2002 12:45:10 +0000 (12:45 +0000)
committerMartin Pool <mbp@samba.org>
Fri, 15 Mar 2002 12:45:10 +0000 (12:45 +0000)
show expected time to complete.  That's kind of inconsistent, but
people can probably cope.  Hopefully we'll get more consistent and
complete progress reporting soon. (Cameron Simpson)

util.c

diff --git a/util.c b/util.c
index 3e4e0f4..c1e0471 100644 (file)
--- a/util.c
+++ b/util.c
@@ -866,7 +866,14 @@ static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now,
     unsigned long diff = msdiff(&start_time, now);
     double        rate = diff ? (double) (ofs-start_ofs) * 1000.0 / diff / 1024.0 : 0;
     const char    *units;
-    double        remain = rate ? (double) (size-ofs) / rate / 1000.0: 0.0;
+    /* If we've finished transferring this file, show the time taken;
+     * otherwise show expected time to complete.  That's kind of
+     * inconsistent, but people can probably cope.  Hopefully we'll
+     * get more consistent and complete progress reporting soon. --
+     * mbp */
+    double        remain = is_last
+                        ? (double) diff / 1000.0
+                        : rate ? (double) (size-ofs) / rate / 1000.0 : 0.0;
     int          remain_h, remain_m, remain_s;
 
     if (rate > 1024*1024) {