X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=script%2Fpublic-inbox-convert;h=8ac111a26cd98add4a0baa59b6b81ae94105b399;hb=eea47b676127bcdba34fe0c1269b7324dd58d479;hp=3182410e0a6f0e5037bc41b3b0a8bd040389f072;hpb=fece7fca6aeac74410a813cffcb0da338017d0ed;p=public-inbox.git diff --git a/script/public-inbox-convert b/script/public-inbox-convert index 3182410e..8ac111a2 100755 --- a/script/public-inbox-convert +++ b/script/public-inbox-convert @@ -4,11 +4,10 @@ use strict; use warnings; use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev); -use PublicInbox::MIME; use PublicInbox::InboxWritable; use PublicInbox::Config; use PublicInbox::V2Writable; -use PublicInbox::Import; +use PublicInbox::Git; use PublicInbox::Spawn qw(spawn); use Cwd 'abs_path'; use File::Copy 'cp'; # preserves permissions: @@ -20,7 +19,6 @@ my %opts = ( '--index!' => \$index, ); GetOptions(%opts) or die "bad command-line args\n$usage"; -GetOptions(%opts) or die "bad command-line args\n$usage"; my $old_dir = shift or die $usage; my $new_dir = shift or die $usage; die "$new_dir exists\n" if -d $new_dir; @@ -44,7 +42,7 @@ unless ($old) { $old = PublicInbox::Inbox->new($old); } $old = PublicInbox::InboxWritable->new($old); -if (($old->{version} || 1) >= 2) { +if ($old->version >= 2) { die "Only conversion from v1 inboxes is supported\n"; } my $new = { %$old }; @@ -147,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; }