From f31850966f7f60b8c58fa44d6948044571c060f6 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Wed, 4 Jun 2008 09:01:02 -0700 Subject: [PATCH] Improved the progress_is_active code to not overwrite the progress output in more circumstances. --- cleanup.c | 4 ---- log.c | 6 ++++++ progress.c | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cleanup.c b/cleanup.c index c0596413..e59565da 100644 --- 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 f486db0d..975ebaf3 100644 --- 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; diff --git a/progress.c b/progress.c index 1d3659e7..86f8ea13 100644 --- a/progress.c +++ b/progress.c @@ -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) -- 2.34.1