Tweak dir xattrs after the writability fudging.
[rsync/rsync.git] / generator.c
index d17e3b9..326ccd8 100644 (file)
@@ -549,8 +549,10 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
 #ifdef SUPPORT_XATTRS
                        if (preserve_xattrs && do_xfers
                         && iflags & (ITEM_REPORT_XATTR|ITEM_TRANSFER)) {
-                               send_xattr_request(NULL, file,
-                                       iflags & ITEM_REPORT_XATTR ? sock_f_out : -1);
+                               int fd = iflags & ITEM_REPORT_XATTR
+                                     && (protocol_version < 31 || !BITS_SET(iflags, ITEM_XNAME_FOLLOWS|ITEM_LOCAL_CHANGE))
+                                      ? sock_f_out : -1;
+                               send_xattr_request(NULL, file, fd);
                        }
 #endif
                } else if (ndx >= 0) {
@@ -1351,13 +1353,6 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                                goto cleanup;
                        }
                }
-#ifdef SUPPORT_XATTRS
-               if (preserve_xattrs && statret == 1)
-                       copy_xattrs(fnamecmpbuf, fname);
-#endif
-               if (set_file_attrs(fname, file, real_ret ? NULL : &real_sx, NULL, 0)
-                   && INFO_GTE(NAME, 1) && code != FNONE && f_out != -1)
-                       rprintf(code, "%s/\n", fname);
 
                /* We need to ensure that the dirs in the transfer have writable
                 * permissions during the time we are putting files within them.
@@ -1374,6 +1369,14 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                }
 #endif
 
+#ifdef SUPPORT_XATTRS
+               if (preserve_xattrs && statret == 1)
+                       copy_xattrs(fnamecmpbuf, fname);
+#endif
+               if (set_file_attrs(fname, file, real_ret ? NULL : &real_sx, NULL, 0)
+                   && INFO_GTE(NAME, 1) && code != FNONE && f_out != -1)
+                       rprintf(code, "%s/\n", fname);
+
                if (real_ret != 0 && one_file_system)
                        real_sx.st.st_dev = filesystem_dev;
                if (inc_recurse) {