Mention the --executability option.
[rsync/rsync.git] / generator.c
index 97395a7..4db5cba 100644 (file)
@@ -45,6 +45,7 @@ extern int preserve_uid;
 extern int preserve_gid;
 extern int preserve_times;
 extern int omit_dir_times;
+extern int delete_mode;
 extern int delete_before;
 extern int delete_during;
 extern int delete_after;
@@ -780,7 +781,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
        char *fnamecmp, *partialptr, *backupptr = NULL;
        char fnamecmpbuf[MAXPATHLEN];
        uchar fnamecmp_type;
-       int del_opts = DEL_TERSE | (delete_after ? DEL_FORCE_RECURSE : 0);
+       int del_opts = DEL_TERSE | (delete_mode ? DEL_FORCE_RECURSE : 0);
 
        if (list_only)
                return;
@@ -854,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)) {