about summary refs log tree commit
diff options
context:
space:
mode:
-rw-r--r--lib/PublicInbox/Inbox.pm15
-rw-r--r--lib/PublicInbox/WWW.pm1
-rw-r--r--lib/PublicInbox/WwwAltId.pm14
3 files changed, 17 insertions, 13 deletions
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index 4f27d1bb..95ffd039 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -376,4 +376,19 @@ sub modified {
         git($self)->modified; # v1
 }
 
+# returns prefix => pathname mapping
+# (pathname is NOT public, but prefix is used for Xapian queries)
+sub altid_map ($) {
+        my ($self) = @_;
+        $self->{-altid_map} //= eval {
+                require PublicInbox::AltId;
+                my $altid = $self->{altid} or return {};
+                my %h = map {;
+                        my $x = PublicInbox::AltId->new($self, $_);
+                        "$x->{prefix}" => $x->{filename}
+                } @$altid;
+                \%h;
+        } // {};
+}
+
 1;
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index 5017f572..56d2c42a 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -170,6 +170,7 @@ sub preload {
 
 sub preload_inbox {
         my $ibx = shift;
+        $ibx->altid_map;
         $ibx->cloneurl;
         $ibx->description;
         $ibx->base_url;
diff --git a/lib/PublicInbox/WwwAltId.pm b/lib/PublicInbox/WwwAltId.pm
index 34641a92..a45d8061 100644
--- a/lib/PublicInbox/WwwAltId.pm
+++ b/lib/PublicInbox/WwwAltId.pm
@@ -10,18 +10,6 @@ use PublicInbox::AltId;
 use PublicInbox::Spawn qw(which);
 our $sqlite3 = $ENV{SQLITE3};
 
-# returns prefix => pathname mapping
-# (pathname is NOT public, but prefix is used for Xapian queries)
-sub altid_map ($) {
-        my ($ibx) = @_;
-        my $altid = $ibx->{altid} or return {};
-        my %h = map {;
-                my $x = PublicInbox::AltId->new($ibx, $_);
-                "$x->{prefix}" => $x->{filename}
-        } @$altid;
-        \%h;
-}
-
 sub sqlite3_missing ($) {
         PublicInbox::WwwResponse::oneshot($_[0], 501, \<<EOF);
 <pre>sqlite3 not available
@@ -51,7 +39,7 @@ sub check_output {
 sub sqldump ($$) {
         my ($ctx, $altid_pfx) = @_;
         my $ibx = $ctx->{-inbox};
-        my $altid_map = $ibx->{-altid_map} //= altid_map($ibx);
+        my $altid_map = $ibx->altid_map;
         my $fn = $altid_map->{$altid_pfx};
         unless (defined $fn) {
                 return PublicInbox::WwwStream::oneshot($ctx, 404, \<<EOF);