diff options
author | Eric Wong <e@yhbt.net> | 2020-01-30 07:51:06 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-01-31 23:00:15 +0000 |
commit | eea47b676127bcdba34fe0c1269b7324dd58d479 (patch) | |
tree | d6ea257567da01e10acab963455f44e61334c78a /script/public-inbox-convert | |
parent | 31cb75037a757c9388f74283a8b1ecb7c5b65f24 (diff) | |
download | public-inbox-eea47b676127bcdba34fe0c1269b7324dd58d479.tar.gz |
If we're reusing the msgmap from a v1 inbox, we also need to ensure the highwater mark doesn't get doubled in the v1->v2 conversion by internally triggering the equivalent of "--reindex" on a fresh v2 inbox. This was needed to convert an indexed v1 inbox which featured messages with multiple Message-IDs in it. Fresh, unindexed clones of v1 inboxes would not have been affected by this.
Diffstat (limited to 'script/public-inbox-convert')
-rwxr-xr-x | script/public-inbox-convert | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/script/public-inbox-convert b/script/public-inbox-convert index 56a810eb..8ac111a2 100755 --- a/script/public-inbox-convert +++ b/script/public-inbox-convert @@ -7,6 +7,7 @@ use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev); use PublicInbox::InboxWritable; use PublicInbox::Config; use PublicInbox::V2Writable; +use PublicInbox::Git; use PublicInbox::Spawn qw(spawn); use Cwd 'abs_path'; use File::Copy 'cp'; # preserves permissions: @@ -144,10 +145,19 @@ $w = $r = undef; close $rd or die "close fast-export: $!\n"; waitpid($pid, 0) or die "waitpid failed: $!\n"; $? == 0 or die "fast-export failed: $?\n"; -my $mm = $old->mm; -$mm->{dbh}->sqlite_backup_to_file("$new_dir/msgmap.sqlite3") if $mm; $v2w->done; +if (my $mm = $old->mm) { + $old->cleanup; + $mm->{dbh}->sqlite_backup_to_file("$new_dir/msgmap.sqlite3"); + + # we want to trigger a reindex, not a from scratch index if + # we're reusing the msgmap from an existing v1 installation. + $v2w->idx_init; + my $epoch0 = PublicInbox::Git->new($v2w->git_init(0)); + chop(my $cmt = $epoch0->qx(qw(rev-parse --verify), $head)); + $v2w->last_epoch_commit(0, $cmt); +} if ($index) { - $v2w->index_sync; + $v2w->index_sync({reindex => 1}); $v2w->done; } |