diff options
author | Matt McCutchen <matt@mattmccutchen.net> | 2008-11-10 06:44:01 -0800 |
---|---|---|
committer | Wayne Davison <wayned@samba.org> | 2008-11-10 07:05:21 -0800 |
commit | d4d56eed8a2dfdd2cd78a19f9c1bae02496427e3 (patch) | |
tree | 586430915a429d4084440870e3e29f192c75e100 /flist.c | |
parent | 3ce3cabe346fed441b840102ec861483d64e126f (diff) | |
download | rsync-d4d56eed8a2dfdd2cd78a19f9c1bae02496427e3.tar.gz rsync-d4d56eed8a2dfdd2cd78a19f9c1bae02496427e3.tar.bz2 rsync-d4d56eed8a2dfdd2cd78a19f9c1bae02496427e3.zip |
Add flist_find_ignore_dirness() and change delete_in_dir() to use it.
This fixes an issue with -K noticed by eric casteleijn, avoids some
inconsistent itemizing when a file/dir is replaced by a dir/file,
and removes a now-obsolete chunk of code from make_file().
Diffstat (limited to 'flist.c')
-rw-r--r-- | flist.c | 41 |
1 files changed, 22 insertions, 19 deletions
@@ -1332,25 +1332,6 @@ struct file_struct *make_file(const char *fname, struct file_list *flist, else if (!pool) F_DEPTH(file) = extra_len / EXTRA_LEN; - /* This code is only used by the receiver when it is building - * a list of files for a delete pass. */ - if (keep_dirlinks && linkname_len && flist) { - STRUCT_STAT st2; - int save_mode = file->mode; - file->mode = S_IFDIR; /* Find a directory with our name. */ - if (flist_find(dir_flist, file) >= 0 - && x_stat(thisname, &st2, NULL) == 0 && S_ISDIR(st2.st_mode)) { - file->modtime = st2.st_mtime; - file->len32 = 0; - file->mode = st2.st_mode; - if (uid_ndx) - F_OWNER(file) = st2.st_uid; - if (gid_ndx) - F_GROUP(file) = st2.st_gid; - } else - file->mode = save_mode; - } - if (basename_len == 0+1) { if (!pool) unmake_file(file); @@ -2533,6 +2514,28 @@ int flist_find(struct file_list *flist, struct file_struct *f) return -1; } +/* Search for an identically-named item in the file list. Differs from + * flist_find in that an item that agrees with "f" in directory-ness is + * preferred but one that does not is still found. */ +int flist_find_ignore_dirness(struct file_list *flist, struct file_struct *f) +{ + mode_t save_mode; + int ndx; + + /* First look for an item that agrees in directory-ness. */ + ndx = flist_find(flist, f); + if (ndx >= 0) + return ndx; + + /* Temporarily flip f->mode to look for an item of opposite + * directory-ness. */ + save_mode = f->mode; + f->mode = S_ISDIR(f->mode) ? S_IFREG : S_IFDIR; + ndx = flist_find(flist, f); + f->mode = save_mode; + return ndx; +} + /* * Free up any resources a file_struct has allocated * and clear the file. |