You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
4.4 KiB

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