When rsync encountered an empty file list, it behaved differently
authorWayne Davison <wayned@samba.org>
Sat, 23 Apr 2005 22:30:08 +0000 (22:30 +0000)
committerWayne Davison <wayned@samba.org>
Sat, 23 Apr 2005 22:30:08 +0000 (22:30 +0000)
when pulling files than when pushing files:  pulling it output a
(mostly) unhelpful error message and then exited with a 0 status,
even when the remote side exited with an error code.  I changed this
to output the normal end summary (when verbose) and to exit with the
status intact (just like when pushing files).

main.c

diff --git a/main.c b/main.c
index 42f4a6f..4cc1d3c 100644 (file)
--- a/main.c
+++ b/main.c
@@ -163,7 +163,9 @@ static void handle_stats(int f)
 
        /* this is the client */
 
-       if (!am_sender) {
+       if (f < 0 && !am_sender) /* e.g. when we got an empty file list. */
+               ; 
+       else if (!am_sender) {
                /* Read the first two in opposite order because the meaning of
                 * read/write swaps when switching from sender to receiver. */
                total_written = read_longint(f);
@@ -808,17 +810,16 @@ int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[])
        if (write_batch && !am_server)
                start_write_batch(f_in);
        flist = recv_file_list(f_in);
-       if (!flist || flist->count == 0) {
-               rprintf(FINFO, "client: nothing to do: "
-                       "perhaps you need to specify some filenames or "
-                       "the --recursive option?\n");
-               exit_cleanup(0);
-       }
        the_file_list = flist;
 
-       local_name = get_local_name(flist,argv[0]);
+       if (flist && flist->count > 0) {
+               local_name = get_local_name(flist, argv[0]);
 
-       status2 = do_recv(f_in,f_out,flist,local_name);
+               status2 = do_recv(f_in, f_out, flist, local_name);
+       } else {
+               handle_stats(-1);
+               output_summary();
+       }
 
        if (pid != -1) {
                if (verbose > 3)