}
}
-sub progress_prepare ($) {
- my ($opt) = @_;
- if ($opt->{quiet}) {
- open my $null, '>', '/dev/null' or
- die "failed to open /dev/null: $!\n";
- $opt->{1} = fileno($null);
- $opt->{-dev_null} = $null;
- } else {
- $opt->{-progress} = sub { print STDERR @_ };
- }
-}
-
sub same_fs_or_die ($$) {
my ($x, $y) = @_;
return if ((stat($x))[0] == (stat($y))[0]); # 0 - st_dev
sub run {
my ($ibx, $task, $opt) = @_; # task = 'cpdb' or 'compact'
my $cb = \&${\"PublicInbox::Xapcmd::$task"};
- progress_prepare($opt ||= {});
+ PublicInbox::Admin::progress_prepare($opt ||= {});
my $dir = $ibx->{mainrepo} or die "no mainrepo in inbox\n";
runnable_or_die($XAPIAN_COMPACT) if $opt->{compact};
my $reindex; # v1:{ from => $x40 }, v2:{ from => [ $x40, $x40, .. ] } }
my $lc = $src->get_metadata('last_commit');
$dst->set_metadata('last_commit', $lc) if $lc;
+ # only the first xapian partition (0) gets 'indexlevel'
+ if ($old =~ m!(?:xapian\d+|xap\d+/0)\z!) {
+ my $l = $src->get_metadata('indexlevel');
+ if ($l eq 'medium') {
+ $dst->set_metadata('indexlevel', $l);
+ }
+ }
+
$it = $src->postlist_begin('');
$end = $src->postlist_end('');
if ($pr) {