X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/860dcf68ad6270ed3d0b9b56bc2cb4a203b28dee..a9d6e6fcacf363b25023aeec3c8d706714ebebcd:/generator.c diff --git a/generator.c b/generator.c index 44a097d4..4db5cbac 100644 --- a/generator.c +++ b/generator.c @@ -855,13 +855,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)) {