From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 2416C1F8DB for ; Wed, 29 Jul 2020 08:43:10 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 3/3] emergency: create full path to PI_EMERGENCY Date: Wed, 29 Jul 2020 08:43:09 +0000 Message-Id: <20200729084309.15772-4-e@yhbt.net> In-Reply-To: <20200729084309.15772-1-e@yhbt.net> References: <20200729084309.15772-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 | 6 ++++-- 1 file 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; }