]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Emergency.pm
update copyrights for 2021
[public-inbox.git] / lib / PublicInbox / Emergency.pm
index 5ce75a797d6b6bc266f4a37edd4a626af61d5317..67f27bc7f18877a127220b400f1a19507c48872d 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2019 all contributors <meta@public-inbox.org>
+# Copyright (C) 2016-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # Emergency Maildir delivery for MDA
@@ -7,16 +7,18 @@ use strict;
 use warnings;
 use Fcntl qw(:DEFAULT SEEK_SET);
 use Sys::Hostname qw(hostname);
-use IO::Handle;
+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;
 }