X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/29a89172f77ed76dcf53612e96dc35daf15d7362..164cb66addee693700c70fed63d996872fcc3edb:/flist.c diff --git a/flist.c b/flist.c index 4e302aa6..f485aca4 100644 --- a/flist.c +++ b/flist.c @@ -366,19 +366,23 @@ int change_pathname(struct file_struct *file, const char *dir, int dirlen) change_dir(orig_dir, CD_SKIP_CHDIR); } - if (!change_dir(dir ? dir : orig_dir, CD_NORMAL)) { + pathname = dir; + pathname_len = dirlen; + + if (!dir) + dir = orig_dir; + + if (!change_dir(dir, CD_NORMAL)) { chdir_error: io_error |= IOERR_GENERAL; rsyserr(FERROR, errno, "change_dir %s failed", full_fname(dir)); - change_dir(orig_dir, CD_NORMAL); + if (dir != orig_dir) + change_dir(orig_dir, CD_NORMAL); pathname = NULL; pathname_len = 0; return 0; } - pathname = dir; - pathname_len = dirlen; - return 1; } @@ -1019,7 +1023,6 @@ struct file_struct *make_file(const char *fname, struct file_list *flist, const char *basename; alloc_pool_t *pool; STRUCT_STAT st; - int excl_ret; char *bp; if (strlcpy(thisname, fname, sizeof thisname) >= sizeof thisname) { @@ -1074,7 +1077,6 @@ struct file_struct *make_file(const char *fname, struct file_list *flist, return NULL; } - /* backup.c calls us with filter_level set to NO_FILTERS. */ if (filter_level == NO_FILTERS) goto skip_filters; @@ -1102,17 +1104,7 @@ struct file_struct *make_file(const char *fname, struct file_list *flist, } else flags &= ~FLAG_CONTENT_DIR; - if (S_ISDIR(st.st_mode)) { - if (flags & FLAG_DOTDIR_NAME) { - /* A "." fname (or "/." fname in relative mode) is - * never excluded. No other trailing-dotdir names - * are possible. */ - excl_ret = 0; - } else - excl_ret = is_excluded(thisname, 1, filter_level); - } else - excl_ret = is_excluded(thisname, 0, filter_level); - if (excl_ret) { + if (is_excluded(thisname, S_ISDIR(st.st_mode) != 0, filter_level)) { if (ignore_perishable) non_perishable_cnt++; return NULL; @@ -1849,7 +1841,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) int64 start_write; int use_ff_fd = 0; int disable_buffering; - int arg_flags, flags = recurse ? FLAG_CONTENT_DIR : 0; + int flags = recurse ? FLAG_CONTENT_DIR : 0; int reading_remotely = filesfrom_host != NULL; int rl_flags = (reading_remotely ? 0 : RL_DUMP_COMMENTS) #ifdef ICONV_OPTION @@ -2031,6 +2023,11 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) continue; } + /* A dot-dir should not be excluded! */ + if (name_type != DOTDIR_NAME + && is_excluded(fbuf, S_ISDIR(st.st_mode) != 0, ALL_FILTERS)) + continue; + if (S_ISDIR(st.st_mode) && !xfer_dirs) { rprintf(FINFO, "skipping directory %s\n", fbuf); continue; @@ -2056,13 +2053,11 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) if (one_file_system) filesystem_dev = st.st_dev; - arg_flags = name_type == DOTDIR_NAME ? FLAG_DOTDIR_NAME : 0; - if (recurse || (xfer_dirs && name_type != NORMAL_NAME)) { struct file_struct *file; - arg_flags |= FLAG_TOP_DIR | FLAG_CONTENT_DIR; file = send_file_name(f, flist, fbuf, &st, - arg_flags | flags, ALL_FILTERS); + FLAG_TOP_DIR | FLAG_CONTENT_DIR | flags, + NO_FILTERS); if (!file) continue; if (inc_recurse) { @@ -2076,7 +2071,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) } else send_if_directory(f, flist, file, fbuf, len, flags); } else - send_file_name(f, flist, fbuf, &st, arg_flags | flags, ALL_FILTERS); + send_file_name(f, flist, fbuf, &st, flags, NO_FILTERS); } gettimeofday(&end_tv, NULL);