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=-3.4 required=3.0 tests=ALL_TRUSTED,AWL,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 A2E6D1FA19 for ; Sun, 20 Dec 2020 06:30:16 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/6] inboxidle: remove needless check for {inboxdir} Date: Sun, 20 Dec 2020 06:30:12 +0000 Message-Id: <20201220063016.20959-3-e@80x24.org> In-Reply-To: <20201220063016.20959-1-e@80x24.org> References: <20201220063016.20959-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: ->each_inbox will never attempt to iterate an object without {inboxdir}, and simplify + short-circuit the corresponding code --- lib/PublicInbox/Config.pm | 7 +++---- lib/PublicInbox/InboxIdle.pm | 7 +------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index cafd9c3b..199ce019 100644 --- a/lib/PublicInbox/Config.pm +++ b/lib/PublicInbox/Config.pm @@ -391,9 +391,9 @@ EOF } } - # backwards compatibility: - $ibx->{inboxdir} //= $self->{"$pfx.mainrepo"}; - if (($ibx->{inboxdir} // '') =~ /\n/s) { + # "mainrepo" is backwards compatibility: + $ibx->{inboxdir} //= $self->{"$pfx.mainrepo"} // return; + if ($ibx->{inboxdir} =~ /\n/s) { warn "E: `$ibx->{inboxdir}' must not contain `\\n'\n"; return; } @@ -415,7 +415,6 @@ EOF } } - return unless defined($ibx->{inboxdir}); my $name = $pfx; $name =~ s/\Apublicinbox\.//; diff --git a/lib/PublicInbox/InboxIdle.pm b/lib/PublicInbox/InboxIdle.pm index 2737bbbd..f1cbc012 100644 --- a/lib/PublicInbox/InboxIdle.pm +++ b/lib/PublicInbox/InboxIdle.pm @@ -7,7 +7,6 @@ package PublicInbox::InboxIdle; use strict; use parent qw(PublicInbox::DS); -use Cwd qw(abs_path); use PublicInbox::Syscall qw(EPOLLIN EPOLLET); my $IN_MODIFY = 0x02; # match Linux inotify my $ino_cls; @@ -22,11 +21,7 @@ require PublicInbox::In2Tie if $ino_cls; sub in2_arm ($$) { # PublicInbox::Config::each_inbox callback my ($ibx, $self) = @_; - my $dir = abs_path($ibx->{inboxdir}); - if (!defined($dir)) { - warn "W: $ibx->{inboxdir} not watched: $!\n"; - return; - } + my $dir = $ibx->{inboxdir}; my $inot = $self->{inot}; my $cur = $self->{pathmap}->{$dir} //= [];