We want to be able to preload that, as well as to access it
in WwwText for a config comment in the config example.
git($self)->modified; # v1
}
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;
+ } // {};
+}
+
sub preload_inbox {
my $ibx = shift;
sub preload_inbox {
my $ibx = shift;
$ibx->cloneurl;
$ibx->description;
$ibx->base_url;
$ibx->cloneurl;
$ibx->description;
$ibx->base_url;
use PublicInbox::Spawn qw(which);
our $sqlite3 = $ENV{SQLITE3};
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
sub sqlite3_missing ($) {
PublicInbox::WwwResponse::oneshot($_[0], 501, \<<EOF);
<pre>sqlite3 not available
sub sqldump ($$) {
my ($ctx, $altid_pfx) = @_;
my $ibx = $ctx->{-inbox};
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);
my $fn = $altid_map->{$altid_pfx};
unless (defined $fn) {
return PublicInbox::WwwStream::oneshot($ctx, 404, \<<EOF);