Improved the progress_is_active code to not overwrite the progress
authorWayne Davison <wayned@samba.org>
Wed, 4 Jun 2008 16:01:02 +0000 (09:01 -0700)
committerWayne Davison <wayned@samba.org>
Wed, 4 Jun 2008 16:01:02 +0000 (09:01 -0700)
output in more circumstances.

cleanup.c
log.c
progress.c

index c059641..e59565d 100644 (file)
--- a/cleanup.c
+++ b/cleanup.c
@@ -27,7 +27,6 @@ extern int am_daemon;
 extern int io_error;
 extern int keep_partial;
 extern int got_xfer_error;
-extern int progress_is_active;
 extern char *partial_dir;
 extern char *logfile_name;
 
@@ -116,9 +115,6 @@ NORETURN void _exit_cleanup(int code, const char *file, int line)
 
                exit_code = unmodified_code = code;
 
-               if (progress_is_active && exit_code && !am_server)
-                       rprintf(FINFO, "\n");
-
                if (verbose > 3) {
                        rprintf(FINFO,
                                "_exit_cleanup(code=%d, file=%s, line=%d): entered\n",
diff --git a/log.c b/log.c
index f486db0..975ebaf 100644 (file)
--- a/log.c
+++ b/log.c
@@ -37,6 +37,7 @@ extern int protocol_version;
 extern int preserve_times;
 extern int uid_ndx;
 extern int gid_ndx;
+extern int progress_is_active;
 extern int stdout_format_has_i;
 extern int stdout_format_has_o_or_i;
 extern int logfile_format_has_i;
@@ -320,6 +321,11 @@ void rwrite(enum logcode code, const char *buf, int len, int is_utf8)
                exit_cleanup(RERR_MESSAGEIO);
        }
 
+       if (progress_is_active && !am_server) {
+               fputc('\n', f);
+               progress_is_active = 0;
+       }
+
        trailing_CR_or_NL = len && (buf[len-1] == '\n' || buf[len-1] == '\r')
                          ? buf[--len] : 0;
 
index 1d3659e..86f8ea1 100644 (file)
@@ -111,13 +111,13 @@ static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now,
                        stats.num_transferred_files,
                        stats.num_files - current_file_index - 1,
                        stats.num_files);
-               progress_is_active = 0;
-       } else {
+       } else
                strlcpy(eol, "\r", sizeof eol);
-               progress_is_active = 1;
-       }
+       progress_is_active = 0;
        rprintf(FCLIENT, "%12s %3d%% %7.2f%s %s%s",
                human_num(ofs), pct, rate, units, rembuf, eol);
+       if (!is_last)
+               progress_is_active = 1;
 }
 
 void set_current_file_index(struct file_struct *file, int ndx)