|
commit ff66fd4bb6cc76488c6ea1e4b651a869847f6375
|
|
Author: Wayne Davison <wayned@samba.org>
|
|
Date: Sat Oct 29 14:47:58 2016 -0700
|
|
|
|
More fixes for --progress quirks.
|
|
|
|
This patch avoids inconsistent evaluation of options in the
|
|
show_filelist_p() function by turning it into a var. We
|
|
also avoid setting "output_needs_newline" if --quiet was
|
|
specified.
|
|
|
|
diff --git a/flist.c b/flist.c
|
|
index 4a9f4e6..54ced36 100644
|
|
--- a/flist.c
|
|
+++ b/flist.c
|
|
@@ -37,6 +37,7 @@ extern int checksum_type;
|
|
extern int module_id;
|
|
extern int ignore_errors;
|
|
extern int numeric_ids;
|
|
+extern int quiet;
|
|
extern int recurse;
|
|
extern int use_qsort;
|
|
extern int xfer_dirs;
|
|
@@ -128,6 +129,7 @@ static char tmp_sum[MAX_DIGEST_LEN];
|
|
|
|
static char empty_sum[MAX_DIGEST_LEN];
|
|
static int flist_count_offset; /* for --delete --progress */
|
|
+static int show_filelist_progress;
|
|
|
|
static void flist_sort_and_clean(struct file_list *flist, int strip_root);
|
|
static void output_flist(struct file_list *flist);
|
|
@@ -140,15 +142,14 @@ void init_flist(void)
|
|
}
|
|
parse_checksum_choice(); /* Sets checksum_type && xfersum_type */
|
|
checksum_len = csum_len_for_type(checksum_type);
|
|
-}
|
|
|
|
-static int show_filelist_p(void)
|
|
-{
|
|
- return INFO_GTE(FLIST, 1) && xfer_dirs && !am_server && !inc_recurse;
|
|
+ show_filelist_progress = INFO_GTE(FLIST, 1) && xfer_dirs && !am_server && !inc_recurse;
|
|
}
|
|
|
|
static void start_filelist_progress(char *kind)
|
|
{
|
|
+ if (quiet)
|
|
+ return;
|
|
rprintf(FCLIENT, "%s ... ", kind);
|
|
output_needs_newline = 1;
|
|
rflush(FINFO);
|
|
@@ -156,25 +157,28 @@ static void start_filelist_progress(char *kind)
|
|
|
|
static void emit_filelist_progress(int count)
|
|
{
|
|
- output_needs_newline = 0; /* avoid a newline in the middle of this filelist-progress output */
|
|
+ if (quiet)
|
|
+ return;
|
|
+ if (output_needs_newline == 2) /* avoid a newline in the middle of this filelist-progress output */
|
|
+ output_needs_newline = 0;
|
|
rprintf(FCLIENT, " %d files...\r", count);
|
|
- output_needs_newline = 1;
|
|
+ output_needs_newline = 2;
|
|
}
|
|
|
|
static void maybe_emit_filelist_progress(int count)
|
|
{
|
|
- if (INFO_GTE(FLIST, 2) && show_filelist_p() && (count % 100) == 0)
|
|
+ if (INFO_GTE(FLIST, 2) && show_filelist_progress && (count % 100) == 0)
|
|
emit_filelist_progress(count);
|
|
}
|
|
|
|
static void finish_filelist_progress(const struct file_list *flist)
|
|
{
|
|
+ output_needs_newline = 0;
|
|
if (INFO_GTE(FLIST, 2)) {
|
|
/* This overwrites the progress line */
|
|
rprintf(FINFO, "%d file%sto consider\n",
|
|
flist->used, flist->used == 1 ? " " : "s ");
|
|
} else {
|
|
- output_needs_newline = 0;
|
|
rprintf(FINFO, "done\n");
|
|
}
|
|
}
|
|
@@ -2089,7 +2093,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
|
|
int implied_dot_dir = 0;
|
|
|
|
rprintf(FLOG, "building file list\n");
|
|
- if (show_filelist_p())
|
|
+ if (show_filelist_progress)
|
|
start_filelist_progress("building file list");
|
|
else if (inc_recurse && INFO_GTE(FLIST, 1) && !am_server)
|
|
rprintf(FCLIENT, "sending incremental file list\n");
|
|
@@ -2363,7 +2367,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
|
|
idev_destroy();
|
|
#endif
|
|
|
|
- if (show_filelist_p())
|
|
+ if (show_filelist_progress)
|
|
finish_filelist_progress(flist);
|
|
|
|
gettimeofday(&end_tv, NULL);
|
|
@@ -2445,7 +2449,7 @@ struct file_list *recv_file_list(int f, int dir_ndx)
|
|
int64 start_read;
|
|
|
|
if (!first_flist) {
|
|
- if (show_filelist_p())
|
|
+ if (show_filelist_progress)
|
|
start_filelist_progress("receiving file list");
|
|
else if (inc_recurse && INFO_GTE(FLIST, 1) && !am_server)
|
|
rprintf(FCLIENT, "receiving incremental file list\n");
|
|
@@ -2541,7 +2545,7 @@ struct file_list *recv_file_list(int f, int dir_ndx)
|
|
if (DEBUG_GTE(FLIST, 2))
|
|
rprintf(FINFO, "received %d names\n", flist->used);
|
|
|
|
- if (show_filelist_p())
|
|
+ if (show_filelist_progress)
|
|
finish_filelist_progress(flist);
|
|
|
|
if (need_unsorted_flist) {
|
|
diff --git a/progress.c b/progress.c
|
|
index 3858fc4..d19fa25 100644
|
|
--- a/progress.c
|
|
+++ b/progress.c
|
|
@@ -25,6 +25,7 @@
|
|
|
|
extern int am_server;
|
|
extern int flist_eof;
|
|
+extern int quiet;
|
|
extern int need_unsorted_flist;
|
|
extern int output_needs_newline;
|
|
extern struct stats stats;
|
|
@@ -127,7 +128,7 @@ static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now,
|
|
pct = ofs == size ? 100 : (int) (100.0 * ofs / size);
|
|
rprintf(FCLIENT, "\r%15s %3d%% %7.2f%s %s%s",
|
|
human_num(ofs), pct, rate, units, rembuf, eol);
|
|
- if (!is_last) {
|
|
+ if (!is_last && !quiet) {
|
|
output_needs_newline = 1;
|
|
rflush(FCLIENT);
|
|
}
|