diff options
author | Magnus Svensson <msvensson@mysql.com> | 2008-10-11 17:06:34 +0200 |
---|---|---|
committer | Magnus Svensson <msvensson@mysql.com> | 2008-10-11 17:06:34 +0200 |
commit | 6a107188489444a498f61ca6a897296eeb5262a0 (patch) | |
tree | 38289d47d09861527c122d2dd5ec7f8727881e27 /mysql-test/lib/My/File | |
parent | 8873148dbfbe29ad03c348a8199b60273b6059be (diff) | |
download | mariadb-git-6a107188489444a498f61ca6a897296eeb5262a0.tar.gz |
WL#4189 Add retry logic to mkpath to avoid temporary permission denied problems
Diffstat (limited to 'mysql-test/lib/My/File')
-rw-r--r-- | mysql-test/lib/My/File/Path.pm | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/mysql-test/lib/My/File/Path.pm b/mysql-test/lib/My/File/Path.pm index 4ec7fbac33d..eeb7546b0b8 100644 --- a/mysql-test/lib/My/File/Path.pm +++ b/mysql-test/lib/My/File/Path.pm @@ -22,8 +22,10 @@ our @EXPORT= qw / rmtree mkpath copytree /; use File::Find; use File::Copy; +use File::Spec; use Carp; use My::Handles; +use My::Platform; sub rmtree { my ($dir)= @_; @@ -58,7 +60,34 @@ sub rmtree { sub mkpath { - goto &File::Path::mkpath; + my $path; + foreach my $dir ( File::Spec->splitdir( @_ ) ) { + #print "dir: $dir\n"; + if ($dir =~ /^[a-z]:/i){ + # Found volume ie. C: + $path= $dir; + next; + } + + $path= File::Spec->catdir($path, $dir); + #print "path: $path\n"; + + next if -d $path; # Path already exist + next if mkdir($path); # mkdir worked + + # mkdir failed, try one more time + next if mkdir($path); + + # mkdir failed again, try two more time after sleep(s) + sleep(1); + next if mkdir($path); + sleep(1); + next if mkdir($path); + + # Report failure and die + croak("Couldn't create directory '$path' ", + " after 4 attempts and 2 sleep(1): $!"); + } }; |