my $ent = { num => $num };
if (defined(my $dir = $lei->{opt}->{dir})) {
$ibx = dir2ibx($lei, $dir) or return;
- $ent->{xdb} = $ibx->xdb and # for inspect_docid
- $docid = PublicInbox::LeiSearch::num2docid($ibx, $num);
+ if (my $srch = $ibx->search) {
+ $ent->{xdb} = $srch->xdb and
+ $docid = $srch->num2docid($num);
+ }
} elsif ($lei->{lse}) {
$ibx = $lei->{lse};
$lei->{lse}->xdb; # set {nshard} for num2docid
use PublicInbox::MID qw(mids mids_for_index);
use Carp qw(croak);
-# get combined docid from over.num:
-# (not generic Xapian, only works with our sharding scheme)
-sub num2docid ($$) {
- my ($self, $num) = @_;
- my $nshard = $self->{nshard};
- ($num - 1) * $nshard + $num % $nshard + 1;
-}
-
sub _msg_kw { # retry_reopen callback
my ($self, $num) = @_;
my $xdb = $self->xdb; # set {nshard} for num2docid;
- xap_terms('K', $xdb, num2docid($self, $num));
+ xap_terms('K', $xdb, $self->num2docid($num));
}
sub msg_keywords { # array or hashref
my $xdb = $self->xdb; # set {nshard};
my %kw;
for my $num (@$nums) { # there should only be one...
- my $doc = $xdb->get_document(num2docid($self, $num));
+ my $doc = $xdb->get_document($self->num2docid($num));
my $x = xap_terms('K', $doc);
%kw = (%kw, %$x);
}
$kw{flagged} = 1 if delete($smsg->{lei_q_tt_flagged});
my @num = $self->over->blob_exists($smsg->{blob});
for my $num (@num) { # there should only be one...
- $doc = $xdb->get_document(num2docid($self, $num));
+ $doc = $xdb->get_document($self->num2docid($num));
$x = xap_terms('K', $doc);
%kw = (%kw, %$x);
if ($want_label) { # JSON/JMAP only
wantarray ? sort(keys(%ret)) : \%ret;
}
+# get combined docid from over.num:
+# (not generic Xapian, only works with our sharding scheme)
+sub num2docid ($$) {
+ my ($self, $num) = @_;
+ my $nshard = $self->{nshard};
+ ($num - 1) * $nshard + $num % $nshard + 1;
+}
+
1;
$f = "$d/t2/msgmap.sqlite3";
$ca = PublicInbox::Msgmap->new_file($f)->created_at;
is($ca, $created{v2}, 'clone + index v1 synced ->created_at');
+ test_lei(sub {
+ lei_ok qw(inspect num:1 --dir), "$d/t1";
+ ok(ref(json_utf8->decode($lei_out)), 'inspect num: on v1');
+ lei_ok qw(inspect num:1 --dir), "$d/t2";
+ ok(ref(json_utf8->decode($lei_out)), 'inspect num: on v2');
+ });
}
ok($td->kill, 'killed -httpd');