Ignore setfacl unless it tells us that it supports the -k option.
[rsync/rsync.git] / receiver.c
index 37c5074..918dad8 100644 (file)
@@ -603,11 +603,11 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
                        fd1 = -1;
                }
 
-               if (fd1 != -1 && !preserve_perms) {
-                       /* if the file exists already and we aren't preserving
-                        * permissions then act as though the remote end sent
-                        * us the file permissions we already have */
-                       file->mode = st.st_mode;
+               /* 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 = fd1 != -1;
+                       file->mode = dest_mode(file->mode, st.st_mode, exists);
                }
 
                /* We now check to see if we are writing file "inplace" */
@@ -681,15 +681,18 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
                }
 
                if ((recv_ok && (!delay_updates || !partialptr)) || inplace) {
-                       finish_transfer(fname, fnametmp, file, recv_ok, 1);
-                       if (partialptr != fname && fnamecmp == partialptr) {
+                       if (partialptr == fname || *partial_dir == '/')
+                               partialptr = NULL;
+                       finish_transfer(fname, fnametmp, partialptr,
+                                       file, recv_ok, 1);
+                       if (fnamecmp == partialptr) {
                                do_unlink(partialptr);
                                handle_partial_dir(partialptr, PDIR_DELETE);
                        }
                } else if (keep_partial && partialptr
                    && handle_partial_dir(partialptr, PDIR_CREATE)) {
-                       finish_transfer(partialptr, fnametmp, file, recv_ok,
-                                       !partial_dir);
+                       finish_transfer(partialptr, fnametmp, NULL,
+                                       file, recv_ok, !partial_dir);
                        if (delay_updates && recv_ok) {
                                set_delayed_bit(i);
                                recv_ok = -1;