From 964ca2eca52c17fa88426a423665eb9e7915142c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 31 Dec 1997 16:39:34 +0000 Subject: [PATCH] simplified the logic of whether to skip a file or not. The -c (always_checksum) option is probably now more useful. --- rsync.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/rsync.c b/rsync.c index 6e7f936a..78022fbb 100644 --- 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; } -- 2.34.1