]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/V2Writable.pm
extsearchidx: enforce -index before -extindex
[public-inbox.git] / lib / PublicInbox / V2Writable.pm
index 07a7fa426e6b7a142419f0c3aa6be0b9b464a6f5..bef3a67a7157bbda72cb0b1933f567d0f6ed2292 100644 (file)
@@ -1073,10 +1073,22 @@ sub sync_prepare ($$) {
                $pfx //= $sync->{ibx}->{inboxdir};
        }
 
-       # reindex stops at the current heads and we later rerun index_sync
-       # without {reindex}
-       my $reindex_heads = $self->last_commits($sync) if $sync->{reindex};
-
+       my $reindex_heads;
+       if ($self->{ibx_map}) {
+               # ExtSearchIdx won't index messages unless they're in
+               # over.sqlite3 for a given inbox, so don't read beyond
+               # what's in the per-inbox index.
+               $reindex_heads = [];
+               my $v = PublicInbox::Search::SCHEMA_VERSION;
+               my $mm = $sync->{ibx}->mm;
+               for my $i (0..$sync->{epoch_max}) {
+                       $reindex_heads->[$i] = $mm->last_commit_xap($v, $i);
+               }
+       } elsif ($sync->{reindex}) { # V2 inbox
+               # reindex stops at the current heads and we later
+               # rerun index_sync without {reindex}
+               $reindex_heads = $self->last_commits($sync);
+       }
        if ($sync->{max_size} = $sync->{-opt}->{max_size}) {
                $sync->{index_oid} = $self->can('index_oid');
        }