In delete_file(): got rid of DEL_NO_RECURSE code and added
authorWayne Davison <wayned@samba.org>
Thu, 20 Jan 2005 23:51:57 +0000 (23:51 +0000)
committerWayne Davison <wayned@samba.org>
Thu, 20 Jan 2005 23:51:57 +0000 (23:51 +0000)
DEL_RECURSE code.  Improved the verbose output of a recursively
deleted directory when --dry-run is specified.

rsync.c

diff --git a/rsync.c b/rsync.c
index e23f1ab..25775a6 100644 (file)
--- a/rsync.c
+++ b/rsync.c
@@ -58,6 +58,7 @@ int delete_file(char *fname, int flags)
        struct dirent *di;
        char buf[MAXPATHLEN];
        STRUCT_STAT st;
+       int zap_dir;
 
        if (!(flags & DEL_DIR)) {
                if (robust_unlink(fname) == 0) {
@@ -74,7 +75,10 @@ int delete_file(char *fname, int flags)
                return -1;
        }
 
-       if (do_rmdir(fname) == 0) {
+       zap_dir = flags & DEL_RECURSE || (force_delete && recurse);
+       if (dry_run && zap_dir)
+               errno = ENOTEMPTY;
+       else if (do_rmdir(fname) == 0) {
                if (verbose && !(flags & DEL_TERSE)) {
                        rprintf(FINFO, "deleting %s/\n",
                                safe_fname(fname));
@@ -83,8 +87,7 @@ int delete_file(char *fname, int flags)
        }
        if (errno == ENOENT)
                return 0;
-       if ((flags & DEL_NO_RECURSE) || !force_delete || !recurse
-           || (errno != ENOTEMPTY && errno != EEXIST)) {
+       if (!zap_dir || (errno != ENOTEMPTY && errno != EEXIST)) {
                rsyserr(FERROR, errno, "delete_file: rmdir %s failed",
                        full_fname(fname));
                return -1;