Avoid changing file_extra_cnt during deletion.
[rsync/rsync.git] / flist.c
diff --git a/flist.c b/flist.c
index 4a50583..f90c286 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -52,12 +52,9 @@ extern int preserve_devices;
 extern int preserve_specials;
 extern int delete_during;
 extern int missing_args;
-extern int uid_ndx;
-extern int gid_ndx;
 extern int eol_nulls;
 extern int relative_paths;
 extern int implied_dirs;
-extern int file_extra_cnt;
 extern int ignore_perishable;
 extern int non_perishable_cnt;
 extern int prune_empty_dirs;
@@ -72,6 +69,7 @@ extern int sender_symlink_iconv;
 extern int output_needs_newline;
 extern int sender_keeps_checksum;
 extern int unsort_ndx;
+extern uid_t our_uid;
 extern struct stats stats;
 extern char *filesfrom_host;
 extern char *usermap, *groupmap;
@@ -1374,10 +1372,12 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
        }
 #endif
        file->mode = st.st_mode;
-       if (uid_ndx) /* Check uid_ndx instead of preserve_uid for del support */
+       if (preserve_uid)
                F_OWNER(file) = st.st_uid;
-       if (gid_ndx) /* Check gid_ndx instead of preserve_gid for del support */
+       if (preserve_gid)
                F_GROUP(file) = st.st_gid;
+       if (am_generator && st.st_uid == our_uid)
+               file->flags |= FLAG_OWNED_BY_US;
 
        if (basename != thisname)
                file->dirname = lastdir;
@@ -3177,13 +3177,14 @@ char *f_name(const struct file_struct *f, char *fbuf)
  * of the dirname string, and also indicates that "dirname" is a MAXPATHLEN
  * buffer (the functions we call will append names onto the end, but the old
  * dir value will be restored on exit). */
-struct file_list *get_dirlist(char *dirname, int dlen, int ignore_filter_rules)
+struct file_list *get_dirlist(char *dirname, int dlen, int flags)
 {
        struct file_list *dirlist;
        char dirbuf[MAXPATHLEN];
        int save_recurse = recurse;
        int save_xfer_dirs = xfer_dirs;
        int save_prune_empty_dirs = prune_empty_dirs;
+       int senddir_fd = flags & GDL_IGNORE_FILTER_RULES ? -2 : -1;
 
        if (dlen < 0) {
                dlen = strlcpy(dirbuf, dirname, MAXPATHLEN);
@@ -3196,7 +3197,7 @@ struct file_list *get_dirlist(char *dirname, int dlen, int ignore_filter_rules)
 
        recurse = 0;
        xfer_dirs = 1;
-       send_directory(ignore_filter_rules ? -2 : -1, dirlist, dirname, dlen, FLAG_CONTENT_DIR);
+       send_directory(senddir_fd, dirlist, dirname, dlen, FLAG_CONTENT_DIR);
        xfer_dirs = save_xfer_dirs;
        recurse = save_recurse;
        if (INFO_GTE(PROGRESS, 1))