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 37FEE1FA19 for ; Mon, 23 Nov 2020 07:06:03 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 04/12] manifest: use ibx->git_epoch method for v2 Date: Mon, 23 Nov 2020 07:05:54 +0000 Message-Id: <20201123070602.9698-5-e@80x24.org> In-Reply-To: <20201123070602.9698-1-e@80x24.org> References: <20201123070602.9698-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We can slightly reduce the amount of version-specific logic, here. --- lib/PublicInbox/Inbox.pm | 1 + lib/PublicInbox/ManifestJsGz.pm | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index 1d18cdf1..64b12345 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -137,6 +137,7 @@ sub git_epoch { $self->version == 2 or return; $self->{"$epoch.git"} ||= do { my $git_dir = "$self->{inboxdir}/git/$epoch.git"; + return unless -d $git_dir; my $g = PublicInbox::Git->new($git_dir); $g->{-httpbackend_limiter} = $self->{-httpbackend_limiter}; # no cleanup needed, we never cat-file off this, only clone diff --git a/lib/PublicInbox/ManifestJsGz.pm b/lib/PublicInbox/ManifestJsGz.pm index 3d8a38ae..3b436827 100644 --- a/lib/PublicInbox/ManifestJsGz.pm +++ b/lib/PublicInbox/ManifestJsGz.pm @@ -7,9 +7,7 @@ use strict; use v5.10.1; use parent qw(PublicInbox::WwwListing); use bytes (); # length -use PublicInbox::Inbox; use PublicInbox::Config; -use PublicInbox::Git; use IO::Compress::Gzip qw(gzip); use HTTP::Date qw(time2str); @@ -26,15 +24,15 @@ sub url_regexp { sub manifest_add ($$;$$) { my ($ctx, $ibx, $epoch, $default_desc) = @_; my $url_path = "/$ibx->{name}"; - my $git_dir = $ibx->{inboxdir}; + my $git; if (defined $epoch) { - $git_dir .= "/git/$epoch.git"; $url_path .= "/git/$epoch.git"; + $git = $ibx->git_epoch($epoch) or return; + } else { + $git = $ibx->git; } - return unless -d $git_dir; - my $git = PublicInbox::Git->new($git_dir); my $ent = $git->manifest_entry($epoch, $default_desc) or return; - $ctx->{-abs2urlpath}->{$git_dir} = $url_path; + $ctx->{-abs2urlpath}->{$git->{git_dir}} = $url_path; my $modified = $ent->{modified}; if ($modified > ($ctx->{-mtime} // 0)) { $ctx->{-mtime} = $modified;