John E. Malmberg convinced me to standardize on #ifs for defined
[rsync/rsync.git] / generator.c
index 8f3177c..31ea939 100644 (file)
@@ -240,6 +240,7 @@ static void recv_generator(char *fname, struct file_list *flist,
                           struct file_struct *file, int ndx,
                           int f_out, int f_out_name)
 {
+       static int missing_below = -1;
        int fd = -1, f_copy = -1;
        STRUCT_STAT st, partial_st;
        struct file_struct *back_file = NULL;
@@ -266,6 +267,10 @@ static void recv_generator(char *fname, struct file_list *flist,
                return;
        }
 
+       if (dry_run && missing_below >= 0 && file->dir.depth <= missing_below) {
+               dry_run--;
+               missing_below = -1;
+       }
        if (dry_run > 1) {
                statret = -1;
                stat_errno = ENOENT;
@@ -303,6 +308,10 @@ static void recv_generator(char *fname, struct file_list *flist,
                        delete_file(fname, DEL_TERSE);
                        statret = -1;
                }
+               if (dry_run && statret != 0 && missing_below < 0) {
+                       missing_below = file->dir.depth;
+                       dry_run++;
+               }
                if (statret != 0 && do_mkdir(fname,file->mode) != 0 && errno != EEXIST) {
                        if (!relative_paths || errno != ENOENT
                            || create_directory_path(fname, orig_umask) < 0
@@ -328,7 +337,7 @@ static void recv_generator(char *fname, struct file_list *flist,
        }
 
        if (preserve_links && S_ISLNK(file->mode)) {
-#if SUPPORT_LINKS
+#ifdef SUPPORT_LINKS
                if (safe_symlinks && unsafe_symlink(file->u.link, fname)) {
                        if (verbose) {
                                rprintf(FINFO,
@@ -446,7 +455,7 @@ static void recv_generator(char *fname, struct file_list *flist,
                                pathjoin(fnamecmpbuf, sizeof fnamecmpbuf,
                                         basis_dir[i], fname);
                        }
-#if HAVE_LINK
+#ifdef HAVE_LINK
                        if (link_dest && match_level == 3 && !dry_run) {
                                if (do_link(fnamecmpbuf, fname) < 0) {
                                        if (verbose) {
@@ -525,12 +534,12 @@ prepare_to_open:
                statret = 0;
        }
 
-       if (dry_run || whole_file > 0) {
+       if (dry_run || read_batch)
+               goto notify_others;
+       if (whole_file > 0) {
                statret = -1;
                goto notify_others;
        }
-       if (read_batch)
-               goto notify_others;
 
        /* open the file */
        fd = do_open(fnamecmp, O_RDONLY, 0);