X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/cc1e997dcdf69d5346a6aed7b8ef10f5309202f8..bb91a624f1f38f4e06ce61901dda54c2ffc52705:/generator.c diff --git a/generator.c b/generator.c index 5884ee49..6b8a9a2d 100644 --- a/generator.c +++ b/generator.c @@ -61,18 +61,18 @@ extern struct exclude_list_struct server_exclude_list; static int skip_file(char *fname, struct file_struct *file, STRUCT_STAT *st) { if (st->st_size != file->length) - return 1; + return 0; if (link_dest) { if (preserve_perms && (st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS)) - return 1; + return 0; if (am_root && preserve_uid && st->st_uid != file->uid) - return 1; + return 0; if (preserve_gid && file->gid != GID_NONE && st->st_gid != file->gid) - return 1; + return 0; } /* if always checksum is set then we use the checksum instead @@ -90,16 +90,16 @@ static int skip_file(char *fname, struct file_struct *file, STRUCT_STAT *st) } file_checksum(fname,sum,st->st_size); return memcmp(sum, file->u.sum, protocol_version < 21 ? 2 - : MD4_SUM_LENGTH) != 0; + : MD4_SUM_LENGTH) == 0; } if (size_only) - return 0; + return 1; if (ignore_times) - return 1; + return 0; - return cmp_modtime(st->st_mtime, file->modtime) != 0; + return cmp_modtime(st->st_mtime, file->modtime) == 0; } @@ -258,15 +258,16 @@ static void generate_and_send_sums(struct map_struct *buf, size_t len, int f_out -/** +/* * Acts on file number @p i from @p flist, whose name is @p fname. * * First fixes up permissions, then generates checksums for the file. * * @note This comment was added later by mbp who was trying to work it * out. It might be wrong. - **/ -void recv_generator(char *fname, struct file_struct *file, int i, int f_out) + */ +static void recv_generator(char *fname, struct file_struct *file, int i, + int f_out) { int fd; STRUCT_STAT st; @@ -482,13 +483,14 @@ void recv_generator(char *fname, struct file_struct *file, int i, int f_out) return; } - if (update_only && cmp_modtime(st.st_mtime,file->modtime)>0 && fnamecmp == fname) { + if (update_only && fnamecmp == fname + && cmp_modtime(st.st_mtime, file->modtime) > 0) { if (verbose > 1) rprintf(FINFO,"%s is newer\n",fname); return; } - if (!skip_file(fname, file, &st)) { + if (skip_file(fname, file, &st)) { if (fnamecmp == fname) set_perms(fname, file, &st, PERMS_REPORT); return; @@ -544,7 +546,7 @@ void recv_generator(char *fname, struct file_struct *file, int i, int f_out) void generate_files(int f, struct file_list *flist, char *local_name) { int i; - int phase=0; + int phase = 0; char fbuf[MAXPATHLEN]; if (verbose > 2) { @@ -587,7 +589,7 @@ void generate_files(int f, struct file_list *flist, char *local_name) phase++; csum_length = SUM_LENGTH; - ignore_times=1; + ignore_times = 1; if (verbose > 2) rprintf(FINFO,"generate_files phase=%d\n",phase);