[dh-make-perl] 01/02: Check existing new directory name before attempting a rename to it

Damyan Ivanov dmn at moszumanska.debian.org
Sat May 23 15:48:07 UTC 2015


This is an automated email from the git hooks/post-receive script.

dmn pushed a commit to branch master
in repository dh-make-perl.

commit ca9379a497cc969b1ccd649565201f1304583702
Author: Andy Beverley <andy at andybev.com>
Date:   Sat Dec 27 21:36:53 2014 +0000

    Check existing new directory name before attempting a rename to it
---
 lib/DhMakePerl/Command/make.pm | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/DhMakePerl/Command/make.pm b/lib/DhMakePerl/Command/make.pm
index c06d04d..92a6152 100644
--- a/lib/DhMakePerl/Command/make.pm
+++ b/lib/DhMakePerl/Command/make.pm
@@ -349,12 +349,19 @@ sub setup_dir {
         $new_maindir = $orig_pwd . "/" . $dist->base_id;
 
         # rename existing directory
+        my $new_inc;
+        my $rename_to = "$new_maindir.$$";
+        while (-d $rename_to)
+        {
+            $new_inc++;
+            $rename_to = "$new_maindir.$$-$new_inc";
+        }
         if ( -d $new_maindir
-            && rename $new_maindir, "$new_maindir.$$" )
+            && rename $new_maindir, $rename_to)
         {
             print '=' x 70, "\n";
             print
-                "Unpacked tarball already existed, directory renamed to $new_maindir.$$\n";
+                "Unpacked tarball already existed, directory renamed to $rename_to\n";
             print '=' x 70, "\n";
         }
         system( "mv", $self->main_dir, "$new_maindir" ) == 0

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/dh-make-perl.git



More information about the Pkg-perl-cvs-commits mailing list