summaryrefslogtreecommitdiff
path: root/mysql-test/lib/My/File
diff options
context:
space:
mode:
authorSven Sandberg <sven@mysql.com>2009-01-08 14:28:40 +0100
committerSven Sandberg <sven@mysql.com>2009-01-08 14:28:40 +0100
commit75017750c3407850be09189b1bc2e77f647a3cfa (patch)
treeef2f1cb12157d2f11c3eacca17270810327bc237 /mysql-test/lib/My/File
parentf0f68e7191817576e6eedf390a1bc674b3a30de0 (diff)
downloadmariadb-git-75017750c3407850be09189b1bc2e77f647a3cfa.tar.gz
BUG#41959: mtr: error message when mkpath() fails and the file exists but is not directory
Problem: when mtr tries to create a directory, and the target exists but is a file instead of directory, it tries several times to create the directory again before it fails. Fix: make it check if the target exists and is a non-directory. mysql-test/lib/My/File/Path.pm: mkpath() now stops with appropriate error message if the target exists but is a non-directory.
Diffstat (limited to 'mysql-test/lib/My/File')
-rw-r--r--mysql-test/lib/My/File/Path.pm8
1 files changed, 6 insertions, 2 deletions
diff --git a/mysql-test/lib/My/File/Path.pm b/mysql-test/lib/My/File/Path.pm
index 7ef1211ff52..7c0004ef526 100644
--- a/mysql-test/lib/My/File/Path.pm
+++ b/mysql-test/lib/My/File/Path.pm
@@ -61,6 +61,9 @@ sub rmtree {
sub mkpath {
my $path;
+
+ die "Usage: mkpath(<path>)" unless @_ == 1;
+
foreach my $dir ( File::Spec->splitdir( @_ ) ) {
#print "dir: $dir\n";
if ($dir =~ /^[a-z]:/i){
@@ -72,8 +75,9 @@ sub mkpath {
$path= File::Spec->catdir($path, $dir);
#print "path: $path\n";
- next if -d $path; # Path already exist
- next if mkdir($path); # mkdir worked
+ next if -d $path; # Path already exists and is a directory
+ croak("File already exists but is not a directory: '$path'") if -e $path;
+ next if mkdir($path);
# mkdir failed, try one more time
next if mkdir($path);