]> Sergey Matveev's repositories - public-inbox.git/commitdiff
emergency: create full path to PI_EMERGENCY
authorEric Wong <e@yhbt.net>
Wed, 29 Jul 2020 08:43:09 +0000 (08:43 +0000)
committerEric Wong <e@yhbt.net>
Wed, 29 Jul 2020 20:59:54 +0000 (20:59 +0000)
It's possible for ~/.public-inbox/ to not exist if PI_CONFIG
points to an alternate location.  Only noticed from the previous
patch fixing t/init.t behavior.

lib/PublicInbox/Emergency.pm

index 02900bb17d11bb4f34c85546dee47ba65b99dd6b..b705e776e676c874ffc7ad0f6c00753bbe1e6e03 100644 (file)
@@ -12,11 +12,13 @@ use IO::Handle; # ->flush, ->autoflush
 sub new {
        my ($class, $dir) = @_;
 
-       -d $dir or mkdir($dir) or die "failed to mkdir($dir): $!\n";
        foreach (qw(new tmp cur)) {
                my $d = "$dir/$_";
                next if -d $d;
-               -d $d or mkdir($d) or die "failed to mkdir($d): $!\n";
+               require File::Path;
+               if (!File::Path::mkpath($d) && !-d $d) {
+                       die "failed to mkpath($d): $!\n";
+               }
        }
        bless { dir => $dir, files => {}, t => 0, cnt => 0, pid => $$ }, $class;
 }