simplified the logic of whether to skip a file or not. The -c
authorAndrew Tridgell <tridge@samba.org>
Wed, 31 Dec 1997 16:39:34 +0000 (16:39 +0000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 31 Dec 1997 16:39:34 +0000 (16:39 +0000)
(always_checksum) option is probably now more useful.

rsync.c

diff --git a/rsync.c b/rsync.c
index 6e7f936..78022fb 100644 (file)
--- a/rsync.c
+++ b/rsync.c
@@ -252,13 +252,36 @@ static int set_perms(char *fname,struct file_struct *file,struct stat *st,
 }
 
 
+/* choose whether to skip a particular file */
+static int skip_file(char *fname,
+                    struct file_struct *file, struct stat *st)
+{
+       if (st->st_size != file->length) {
+               return 0;
+       }
+       
+       /* if always checksum is set then we use the checksum instead 
+          of the file time to determine whether to sync */
+       if (always_checksum && S_ISREG(st->st_mode)) {
+               char sum[MD4_SUM_LENGTH];
+               file_checksum(fname,sum,st->st_size);
+               return (memcmp(sum,file->sum,csum_length) == 0);
+       }
+
+       if (ignore_times) {
+               return 0;
+       }
+
+       return (st->st_mtime == file->modtime);
+}
+
+
 void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
 {  
   int fd;
   struct stat st;
   struct map_struct *buf;
   struct sum_struct *s;
-  char sum[MD4_SUM_LENGTH];
   int statret;
   struct file_struct *file = &flist->files[i];
 
@@ -388,14 +411,7 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
     return;
   }
 
-  if (always_checksum && S_ISREG(st.st_mode)) {
-    file_checksum(fname,sum,st.st_size);
-  }
-
-  if (st.st_size == file->length &&
-      ((!ignore_times && st.st_mtime == file->modtime) ||
-       (always_checksum && S_ISREG(st.st_mode) &&        
-       memcmp(sum,file->sum,csum_length) == 0))) {
+  if (skip_file(fname, file, &st)) {
     set_perms(fname,file,&st,1);
     return;
   }