about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-07-29 08:43:09 +0000
committerEric Wong <e@yhbt.net>2020-07-29 20:59:54 +0000
commit9e0c2886493863b4bc6483ce0a3bfd3d599c8c87 (patch)
tree2df3debc40a7d1ce89c8ffcbf8543b16f4a93777 /lib
parent8fa5d57855d38f2e6f7e6d9c2eefcbbf0c4d0ac9 (diff)
downloadpublic-inbox-9e0c2886493863b4bc6483ce0a3bfd3d599c8c87.tar.gz
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/Emergency.pm6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/PublicInbox/Emergency.pm b/lib/PublicInbox/Emergency.pm
index 02900bb1..b705e776 100644
--- a/lib/PublicInbox/Emergency.pm
+++ b/lib/PublicInbox/Emergency.pm
@@ -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;
 }