about summary refs log tree commit homepage
path: root/lib/PublicInbox/Inbox.pm
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-02-22 07:15:54 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-02-28 18:42:44 +0000
commit126d94b10886b02a3936f1429cab1eaea21b6025 (patch)
treedcaa2e2aa48fc1a42f832e335abd6a268357cae6 /lib/PublicInbox/Inbox.pm
parent61ecf6a904b868ce791115231b11859d725c6113 (diff)
downloadpublic-inbox-126d94b10886b02a3936f1429cab1eaea21b6025.tar.gz
Fortunately, Xapian multiple database support makes things
easier but we still need to handle the skeleton DB separately.
Diffstat (limited to 'lib/PublicInbox/Inbox.pm')
-rw-r--r--lib/PublicInbox/Inbox.pm21
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index e7856e3c..f000a950 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -73,6 +73,10 @@ sub new {
         _set_limiter($opts, $pi_config, 'httpbackend');
         _set_uint($opts, 'feedmax', 25);
         $opts->{nntpserver} ||= $pi_config->{'publicinbox.nntpserver'};
+        my $dir = $opts->{mainrepo};
+        if (defined $dir && -f "$dir/msgmap.sqlite3") { # XXX DIRTY
+                $opts->{version} = 2;
+        }
         bless $opts, $class;
 }
 
@@ -92,7 +96,12 @@ sub mm {
         my ($self) = @_;
         $self->{mm} ||= eval {
                 _cleanup_later($self);
-                PublicInbox::Msgmap->new($self->{mainrepo});
+                my $dir = $self->{mainrepo};
+                if (($self->{version} || 1) >= 2) {
+                        PublicInbox::Msgmap->new_file("$dir/msgmap.sqlite3");
+                } else {
+                        PublicInbox::Msgmap->new($dir);
+                }
         };
 }
 
@@ -100,7 +109,7 @@ sub search {
         my ($self) = @_;
         $self->{search} ||= eval {
                 _cleanup_later($self);
-                PublicInbox::Search->new($self->{mainrepo}, $self->{altid});
+                PublicInbox::Search->new($self, $self->{altid});
         };
 }
 
@@ -229,7 +238,7 @@ sub msg_by_smsg ($$;$) {
         # backwards compat to fallback to msg_by_mid
         # TODO: remove if we bump SCHEMA_VERSION in Search.pm:
         defined(my $blob = $smsg->{blob}) or
-                        return msg_by_mid($self, $smsg->mid);
+                        return msg_by_path($self, mid2path($smsg->mid), $ref);
 
         my $str = git($self)->cat_file($blob, $ref);
         $$str =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s if $str;
@@ -243,7 +252,11 @@ sub path_check {
 
 sub msg_by_mid ($$;$) {
         my ($self, $mid, $ref) = @_;
-        msg_by_path($self, mid2path($mid), $ref);
+        my $srch = search($self) or
+                        return msg_by_path($self, mid2path($mid), $ref);
+        my $smsg = $srch->lookup_skeleton($mid) or return;
+        $smsg->load_expand;
+        msg_by_smsg($self, $smsg, $ref);
 }
 
 1;