fixed a bug that made us use only 16 bits of the file checksum when
[rsync/rsync.git] / main.c
diff --git a/main.c b/main.c
index 56a078b..807409e 100644 (file)
--- a/main.c
+++ b/main.c
@@ -23,8 +23,6 @@ time_t starttime = 0;
 
 struct stats stats;
 
-extern int csum_length;
-
 extern int verbose;
 
 static void report(int f)
@@ -34,14 +32,17 @@ static void report(int f)
        extern int am_sender;
        extern int am_daemon;
        extern int do_stats;
+       extern int remote_version;
+       int send_stats;
 
        if (am_daemon) {
                log_exit(0, __FILE__, __LINE__);
                if (f == -1 || !am_sender) return;
        }
 
+       send_stats = verbose || (remote_version >= 20);
        if (am_server) {
-               if (verbose && am_sender) {
+               if (am_sender && send_stats) {
                        int64 w;
                        /* store total_written in a temporary
                            because write_longint changes it */
@@ -55,12 +56,7 @@ static void report(int f)
 
        /* this is the client */
            
-       if (!am_sender && verbose) {
-               /* note that if (!verbose && do_stats) then these values will
-                    be taken from the receiver side's copy.  The total size
-                    is identical but the bytes read and written are slightly
-                    different.  It's done this way to avoid modifying the
-                    protocol to support --stats without -v. */
+       if (!am_sender && send_stats) {
                int64 r;
                stats.total_written = read_longint(f);
                /* store total_read in a temporary, read_longint changes it */
@@ -70,6 +66,12 @@ static void report(int f)
        }
 
        if (do_stats) {
+               if (!am_sender && !send_stats) {
+                   /* missing the bytes written by the generator */
+                   rprintf(FINFO, "\nCannot show stats as receiver because remote protocol version is less than 20\n");
+                   rprintf(FINFO, "Use --stats -v to show stats\n");
+                   return;
+               }
                rprintf(FINFO,"\nNumber of files: %d\n", stats.num_files);
                rprintf(FINFO,"Number of files transferred: %d\n", 
                       stats.num_transferred_files);
@@ -204,7 +206,7 @@ static char *get_local_name(struct file_list *flist,char *name)
                return name;
        }
 
-       if (flist->count == 1)
+       if (flist->count <= 1)
                return name;
 
        if (do_mkdir(name,0777 & ~orig_umask) != 0) {
@@ -330,6 +332,7 @@ static void do_server_recv(int f_in, int f_out, int argc,char *argv[])
        char *local_name=NULL;
        char *dir = NULL;
        extern int delete_mode;
+       extern int delete_excluded;
        extern int am_daemon;
 
        if (verbose > 2)
@@ -346,12 +349,12 @@ static void do_server_recv(int f_in, int f_out, int argc,char *argv[])
                }    
        }
 
-       if (delete_mode)
+       if (delete_mode && !delete_excluded)
                recv_exclude_list(f_in);
 
        flist = recv_file_list(f_in);
-       if (!flist || flist->count == 0) {
-               rprintf(FERROR,"server_recv: nothing to do\n");
+       if (!flist) {
+               rprintf(FERROR,"server_recv: recv_file_list error\n");
                exit_cleanup(RERR_FILESELECT);
        }
        
@@ -403,9 +406,10 @@ int client_run(int f_in, int f_out, int pid, int argc, char *argv[])
        if (am_sender) {
                extern int cvs_exclude;
                extern int delete_mode;
+               extern int delete_excluded;
                if (cvs_exclude)
                        add_cvs_excludes();
-               if (delete_mode) 
+               if (delete_mode && !delete_excluded
                        send_exclude_list(f_out);
                flist = send_file_list(f_out,argc,argv);
                if (verbose > 3)