1 commit ff66fd4bb6cc76488c6ea1e4b651a869847f6375
2 Author: Wayne Davison <wayned@samba.org>
3 Date: Sat Oct 29 14:47:58 2016 -0700
5 More fixes for --progress quirks.
7 This patch avoids inconsistent evaluation of options in the
8 show_filelist_p() function by turning it into a var. We
9 also avoid setting "output_needs_newline" if --quiet was
12 diff --git a/flist.c b/flist.c
13 index 4a9f4e6..54ced36 100644
16 @@ -37,6 +37,7 @@ extern int checksum_type;
18 extern int ignore_errors;
19 extern int numeric_ids;
24 @@ -128,6 +129,7 @@ static char tmp_sum[MAX_DIGEST_LEN];
26 static char empty_sum[MAX_DIGEST_LEN];
27 static int flist_count_offset; /* for --delete --progress */
28 +static int show_filelist_progress;
30 static void flist_sort_and_clean(struct file_list *flist, int strip_root);
31 static void output_flist(struct file_list *flist);
32 @@ -140,15 +142,14 @@ void init_flist(void)
34 parse_checksum_choice(); /* Sets checksum_type && xfersum_type */
35 checksum_len = csum_len_for_type(checksum_type);
38 -static int show_filelist_p(void)
40 - return INFO_GTE(FLIST, 1) && xfer_dirs && !am_server && !inc_recurse;
41 + show_filelist_progress = INFO_GTE(FLIST, 1) && xfer_dirs && !am_server && !inc_recurse;
44 static void start_filelist_progress(char *kind)
48 rprintf(FCLIENT, "%s ... ", kind);
49 output_needs_newline = 1;
51 @@ -156,25 +157,28 @@ static void start_filelist_progress(char *kind)
53 static void emit_filelist_progress(int count)
55 - output_needs_newline = 0; /* avoid a newline in the middle of this filelist-progress output */
58 + if (output_needs_newline == 2) /* avoid a newline in the middle of this filelist-progress output */
59 + output_needs_newline = 0;
60 rprintf(FCLIENT, " %d files...\r", count);
61 - output_needs_newline = 1;
62 + output_needs_newline = 2;
65 static void maybe_emit_filelist_progress(int count)
67 - if (INFO_GTE(FLIST, 2) && show_filelist_p() && (count % 100) == 0)
68 + if (INFO_GTE(FLIST, 2) && show_filelist_progress && (count % 100) == 0)
69 emit_filelist_progress(count);
72 static void finish_filelist_progress(const struct file_list *flist)
74 + output_needs_newline = 0;
75 if (INFO_GTE(FLIST, 2)) {
76 /* This overwrites the progress line */
77 rprintf(FINFO, "%d file%sto consider\n",
78 flist->used, flist->used == 1 ? " " : "s ");
80 - output_needs_newline = 0;
81 rprintf(FINFO, "done\n");
84 @@ -2089,7 +2093,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
85 int implied_dot_dir = 0;
87 rprintf(FLOG, "building file list\n");
88 - if (show_filelist_p())
89 + if (show_filelist_progress)
90 start_filelist_progress("building file list");
91 else if (inc_recurse && INFO_GTE(FLIST, 1) && !am_server)
92 rprintf(FCLIENT, "sending incremental file list\n");
93 @@ -2363,7 +2367,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
97 - if (show_filelist_p())
98 + if (show_filelist_progress)
99 finish_filelist_progress(flist);
101 gettimeofday(&end_tv, NULL);
102 @@ -2445,7 +2449,7 @@ struct file_list *recv_file_list(int f, int dir_ndx)
106 - if (show_filelist_p())
107 + if (show_filelist_progress)
108 start_filelist_progress("receiving file list");
109 else if (inc_recurse && INFO_GTE(FLIST, 1) && !am_server)
110 rprintf(FCLIENT, "receiving incremental file list\n");
111 @@ -2541,7 +2545,7 @@ struct file_list *recv_file_list(int f, int dir_ndx)
112 if (DEBUG_GTE(FLIST, 2))
113 rprintf(FINFO, "received %d names\n", flist->used);
115 - if (show_filelist_p())
116 + if (show_filelist_progress)
117 finish_filelist_progress(flist);
119 if (need_unsorted_flist) {
120 diff --git a/progress.c b/progress.c
121 index 3858fc4..d19fa25 100644
126 extern int am_server;
127 extern int flist_eof;
129 extern int need_unsorted_flist;
130 extern int output_needs_newline;
131 extern struct stats stats;
132 @@ -127,7 +128,7 @@ static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now,
133 pct = ofs == size ? 100 : (int) (100.0 * ofs / size);
134 rprintf(FCLIENT, "\r%15s %3d%% %7.2f%s %s%s",
135 human_num(ofs), pct, rate, units, rembuf, eol);
137 + if (!is_last && !quiet) {
138 output_needs_newline = 1;