chiark / gitweb /
When cleaning up after failed clone, stat the to-be-cleaned-up directory before runni...
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 22 May 2016 14:24:08 +0000 (15:24 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 1 Jul 2016 21:37:38 +0000 (22:37 +0100)
debian/changelog
dgit

index 1f73c7c320680c1ada8289ab73fded77856f3e0f..f3a88a2fe8a7675f7c1d1186d0896b2f56a80ac9 100644 (file)
@@ -7,6 +7,10 @@ dgit (1.5~~) unstable; urgency=medium
     has been changed recently and now this default setting is very awkward
     to change for the dgit user.
 
+  Bugfixes:
+  * When cleaning up after failed clone, stat the to-be-cleaned-up
+    directory before running rmtree on it.  Closes:#796773.
+
   Test suite:
   * When sbuild fails, do not crash due to sed not finding the log
     file.  Instead, simply tolerate the absence of the log file.
diff --git a/dgit b/dgit
index 9edc6577a4feb3a46129321570bac783ade70c11..91f43af087372c02b0f6ad719f93a60b07a94002 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -2131,7 +2131,13 @@ sub cmd_clone {
                return if $!==&ENOENT;
                die "chdir $cwd_remove: $!";
            }
-           rmtree($dstdir) or die "remove $dstdir: $!\n";
+           if (stat $dstdir) {
+               rmtree($dstdir) or die "remove $dstdir: $!\n";
+           } elsif (!grep { $! == $_ }
+                    (ENOENT, ENOTDIR, EACCES, EPERM, ELOOP)) {
+           } else {
+               print STDERR "check whether to remove $dstdir: $!\n";
+           }
        };
     }