A recent posting here got me thinking about having the --progress output tell the user about how many files were left to go in the transfer. I submit the attached patch which outputs an extra suffix onto the progress line at the end of each file's transfer (so it only appears once per file, not on every status update). The output would look like this: [...] flist.c 35671 100% 6.67MB/s 0:00:00 (#3; 262 more to check) flist.o 87288 100% 4.59MB/s 0:00:00 (#4; 261 more to check) log.c 13812 100% 12.50MB/s 0:00:00 (#5; 221 more to check) [...] The "to check" part is perhaps a little verbose, but it helps to alert the user that we're not talking about how many files are left to transfer (since we won't know that number until we check them) and the "more" number will often not go down to zero (if the final file in the list is up-to-date). Thoughts? Suggestions? ..wayne.. -------------- next part -------------- --- log.c 13 Jan 2004 04:50:45 -0000 1.69 +++ log.c 13 Jan 2004 04:51:01 -0000 @@ -191,6 +191,8 @@ void log_init(void) #ifndef LOG_NDELAY logit(LOG_INFO,"rsyncd started\n"); #endif + + stats.current_file_index = -1; } void log_open(void) --- progress.c 13 Jan 2004 05:13:57 -0000 1.5 +++ progress.c 13 Jan 2004 05:00:29 -0000 @@ -21,6 +21,7 @@ #include "rsync.h" +extern struct stats stats; extern int am_server; static OFF_T last_ofs; @@ -45,6 +46,7 @@ static unsigned long msdiff(struct timev static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now, int is_last) { + char eol[256]; int pct = (ofs == size) ? 100 : (int)((100.0*ofs)/size); unsigned long diff = msdiff(&start_time, now); double rate = diff ? (double) (ofs-start_ofs) * 1000.0 / diff / 1024.0 : 0; @@ -72,10 +74,16 @@ static void rprint_progress(OFF_T ofs, O remain_m = (int) (remain / 60.0) % 60; remain_h = (int) (remain / 3600.0); + if (is_last) { + int todo = stats.num_files - stats.num_untransferred_files + - stats.num_transferred_files; + snprintf(eol, sizeof eol, " (#%d; %d more to check)\n", + stats.num_transferred_files, todo); + } else + strcpy(eol, "\r"); rprintf(FINFO, "%12.0f %3d%% %7.2f%s %4d:%02d:%02d%s", (double) ofs, pct, rate, units, - remain_h, remain_m, remain_s, - is_last ? "\n" : "\r"); + remain_h, remain_m, remain_s, eol); } void end_progress(OFF_T size) --- receiver.c 8 Jan 2004 00:45:41 -0000 1.61 +++ receiver.c 13 Jan 2004 06:19:41 -0000 @@ -328,6 +328,9 @@ int recv_files(int f_in,struct file_list file = flist->files[i]; + if (phase == 0) + stats.num_untransferred_files += i - stats.current_file_index - 1; + stats.current_file_index = i; stats.num_transferred_files++; stats.total_transferred_size += file->length; cleanup_got_literal = 0; --- rsync.h 12 Jan 2004 03:48:43 -0000 1.170 +++ rsync.h 13 Jan 2004 06:17:50 -0000 @@ -477,6 +477,8 @@ struct stats { int flist_size; int num_files; int num_transferred_files; + int num_untransferred_files; + int current_file_index; }; --- sender.c 10 Jan 2004 20:16:18 -0000 1.32 +++ sender.c 13 Jan 2004 06:19:53 -0000 @@ -25,6 +25,7 @@ extern struct stats stats; extern int io_error; extern int dry_run; extern int am_server; +extern int do_progress; /** @@ -155,6 +156,9 @@ void send_files(struct file_list *flist, file = flist->files[i]; + if (phase == 0) + stats.num_untransferred_files += i - stats.current_file_index - 1; + stats.current_file_index = i; stats.num_transferred_files++; stats.total_transferred_size += file->length;
YES YES YES YES YES me likey me likey me ruv you rong time. I've been wanting something like this forever. Who really gives a rat's ass about the %age of the current file, most of the time; it's ALL about the percentage of the total job done. I'd love to see this make a point-release so we don't have to worry about patching it in. -J Wayne Davison wrote:> A recent posting here got me thinking about having the --progress > output tell the user about how many files were left to go in the > transfer. I submit the attached patch which outputs an extra suffix > onto the progress line at the end of each file's transfer (so it > only appears once per file, not on every status update). The output > would look like this: > > [...] > flist.c > 35671 100% 6.67MB/s 0:00:00 (#3; 262 more to check) > flist.o > 87288 100% 4.59MB/s 0:00:00 (#4; 261 more to check) > log.c > 13812 100% 12.50MB/s 0:00:00 (#5; 221 more to check) > [...] > > The "to check" part is perhaps a little verbose, but it helps to > alert the user that we're not talking about how many files are left > to transfer (since we won't know that number until we check them) > and the "more" number will often not go down to zero (if the final > file in the list is up-to-date). > > Thoughts? Suggestions? > > ..wayne.. > > > ------------------------------------------------------------------------ > > --- log.c 13 Jan 2004 04:50:45 -0000 1.69 > +++ log.c 13 Jan 2004 04:51:01 -0000 > @@ -191,6 +191,8 @@ void log_init(void) > #ifndef LOG_NDELAY > logit(LOG_INFO,"rsyncd started\n"); > #endif > + > + stats.current_file_index = -1; > } > > void log_open(void) > --- progress.c 13 Jan 2004 05:13:57 -0000 1.5 > +++ progress.c 13 Jan 2004 05:00:29 -0000 > @@ -21,6 +21,7 @@ > > #include "rsync.h" > > +extern struct stats stats; > extern int am_server; > > static OFF_T last_ofs; > @@ -45,6 +46,7 @@ static unsigned long msdiff(struct timev > static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now, > int is_last) > { > + char eol[256]; > int pct = (ofs == size) ? 100 : (int)((100.0*ofs)/size); > unsigned long diff = msdiff(&start_time, now); > double rate = diff ? (double) (ofs-start_ofs) * 1000.0 / diff / 1024.0 : 0; > @@ -72,10 +74,16 @@ static void rprint_progress(OFF_T ofs, O > remain_m = (int) (remain / 60.0) % 60; > remain_h = (int) (remain / 3600.0); > > + if (is_last) { > + int todo = stats.num_files - stats.num_untransferred_files > + - stats.num_transferred_files; > + snprintf(eol, sizeof eol, " (#%d; %d more to check)\n", > + stats.num_transferred_files, todo); > + } else > + strcpy(eol, "\r"); > rprintf(FINFO, "%12.0f %3d%% %7.2f%s %4d:%02d:%02d%s", > (double) ofs, pct, rate, units, > - remain_h, remain_m, remain_s, > - is_last ? "\n" : "\r"); > + remain_h, remain_m, remain_s, eol); > } > > void end_progress(OFF_T size) > --- receiver.c 8 Jan 2004 00:45:41 -0000 1.61 > +++ receiver.c 13 Jan 2004 06:19:41 -0000 > @@ -328,6 +328,9 @@ int recv_files(int f_in,struct file_list > > file = flist->files[i]; > > + if (phase == 0) > + stats.num_untransferred_files += i - stats.current_file_index - 1; > + stats.current_file_index = i; > stats.num_transferred_files++; > stats.total_transferred_size += file->length; > cleanup_got_literal = 0; > --- rsync.h 12 Jan 2004 03:48:43 -0000 1.170 > +++ rsync.h 13 Jan 2004 06:17:50 -0000 > @@ -477,6 +477,8 @@ struct stats { > int flist_size; > int num_files; > int num_transferred_files; > + int num_untransferred_files; > + int current_file_index; > }; > > > --- sender.c 10 Jan 2004 20:16:18 -0000 1.32 > +++ sender.c 13 Jan 2004 06:19:53 -0000 > @@ -25,6 +25,7 @@ extern struct stats stats; > extern int io_error; > extern int dry_run; > extern int am_server; > +extern int do_progress; > > > /** > @@ -155,6 +156,9 @@ void send_files(struct file_list *flist, > > file = flist->files[i]; > > + if (phase == 0) > + stats.num_untransferred_files += i - stats.current_file_index - 1; > + stats.current_file_index = i; > stats.num_transferred_files++; > stats.total_transferred_size += file->length; > >
> A recent posting here got me thinking about having the --progress output > tell the user about how many files were left to go in the transfer. I > submit the attached patch which outputs an extra suffix onto the > progress line at the end of each file's transfer (so it only appears > once per file, not on every status update).I love it! I've always felt that rsync always needed something like this. -Chuck -- http://www.quantumlinux.com Quantum Linux Laboratories, LLC. ACCELERATING Business with Open Technology "The measure of the restoration lies in the extent to which we apply social values more noble than mere monetary profit." - FDR
On Mon, Jan 12, 2004 at 10:37:40PM -0800, Wayne Davison wrote:> A recent posting here got me thinking about having the --progress > output tell the user about how many files were left to go in the > transfer. I submit the attached patch which outputs an extra suffix > onto the progress line at the end of each file's transfer (so it > only appears once per file, not on every status update). The output > would look like this: > > [...] > flist.c > 35671 100% 6.67MB/s 0:00:00 (#3; 262 more to check) > flist.o > 87288 100% 4.59MB/s 0:00:00 (#4; 261 more to check) > log.c > 13812 100% 12.50MB/s 0:00:00 (#5; 221 more to check) > [...] > > The "to check" part is perhaps a little verbose, but it helps to > alert the user that we're not talking about how many files are left > to transfer (since we won't know that number until we check them) > and the "more" number will often not go down to zero (if the final > file in the list is up-to-date). > > Thoughts? Suggestions?Seems over-complicated to me. How about "(%d of %d files)\n", cur_index, flist->count; For that you just need cur_index to come from i in recv_files() or send_file(); That gives index into flist as it is being walked. If you wanted to have something more complicated i'd go with using bytecounts of transferred plus skipped as a percentage of total so when complete it would be 100% -- ________________________________________________________________ J.W. Schultz Pegasystems Technologies email address: jw@pegasys.ws Remember Cernan and Schmitt