X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/e35d9f2d6d5f1cb1f87736748d5249ce18b10da0..b988781801eedf817bf7b2e7fc62ceb238a1dc6b:/generator.c diff --git a/generator.c b/generator.c index 44a097d4..c000dcbf 100644 --- a/generator.c +++ b/generator.c @@ -349,8 +349,7 @@ void itemize(struct file_struct *file, int ndx, int statret, STRUCT_STAT *st, && (!(iflags & ITEM_XNAME_FOLLOWS) || *xname)) || (keep_time && cmp_modtime(file->modtime, st->st_mtime) != 0)) iflags |= ITEM_REPORT_TIME; - if (preserve_perms - && (file->mode & CHMOD_BITS) != (st->st_mode & CHMOD_BITS)) + if ((file->mode & CHMOD_BITS) != (st->st_mode & CHMOD_BITS)) iflags |= ITEM_REPORT_PERMS; if (preserve_uid && am_root && file->uid != st->st_uid) iflags |= ITEM_REPORT_OWNER; @@ -855,13 +854,12 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, return; } - if (statret == 0 && !preserve_perms - && S_ISDIR(st.st_mode) == S_ISDIR(file->mode)) { - /* if the file exists already and we aren't perserving - * permissions then act as though the remote end sent - * us the file permissions we already have */ - file->mode = (file->mode & ~CHMOD_BITS) - | (st.st_mode & CHMOD_BITS); + /* If we're not preserving permissions, change the file-list's + * mode based on the local permissions and some heuristics. */ + if (!preserve_perms) { + int exists = statret == 0 + && S_ISDIR(st.st_mode) == S_ISDIR(file->mode); + file->mode = dest_mode(file->mode, st.st_mode, exists); } if (S_ISDIR(file->mode)) {