When --dry-run is set, note when a directory is missing and avoid
authorWayne Davison <wayned@samba.org>
Sat, 12 Feb 2005 21:18:58 +0000 (21:18 +0000)
committerWayne Davison <wayned@samba.org>
Sat, 12 Feb 2005 21:18:58 +0000 (21:18 +0000)
trying to stat() any items inside that dir's hierarchy.  This fixes
a bug where a symlink to a dir getting replaced by a dir with
identical contents to the dir at the other end of the symlink would
not report the updated files in the new hierarchy. (See bug #1673)

generator.c

index ad28e83..52daa7c 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