diff options
author | Eric Wong <e@yhbt.net> | 2020-08-07 01:14:00 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-08-07 23:45:34 +0000 |
commit | 14f9a4dc0e9d77910df364adbe329246bf1693fd (patch) | |
tree | 67bac0b0d474d5d03ff1bf6d8c0307a57c43964e /lib/PublicInbox/Xapcmd.pm | |
parent | 62068fafcb40c2f91d31cf3fa5e775ecc52a6ba8 (diff) | |
download | public-inbox-14f9a4dc0e9d77910df364adbe329246bf1693fd.tar.gz |
I find myself mindlessly adding "-c" to public-inbox-index, and other users may do the same. Instead of erroring out, we'll just silently ignore it, for now and allow public-inbox-compact to work on SQLite-only inboxes. We'll only check for xapian-compact if search exists, since it won't be needed in case we support SQLite VACUUM.
Diffstat (limited to 'lib/PublicInbox/Xapcmd.pm')
-rw-r--r-- | lib/PublicInbox/Xapcmd.pm | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/PublicInbox/Xapcmd.pm b/lib/PublicInbox/Xapcmd.pm index f1c80831..8d09ed27 100644 --- a/lib/PublicInbox/Xapcmd.pm +++ b/lib/PublicInbox/Xapcmd.pm @@ -167,9 +167,11 @@ sub prepare_run { my ($ibx, $opt) = @_; my $tmp = {}; # old shard dir => File::Temp->newdir object or undef my @queue; # ([old//src,newdir]) - list of args for cpdb() or compact() - - my $old = $ibx->search->xdir(1); - -d $old or die "$old does not exist\n"; + my $old; + if (my $srch = $ibx->search) { + $old = $srch->xdir(1); + -d $old or die "$old does not exist\n"; + } my $reshard = $opt->{reshard}; if (defined $reshard && $reshard <= 0) { die "--reshard must be a positive number\n"; @@ -177,7 +179,7 @@ sub prepare_run { # we want temporary directories to be as deep as possible, # so v2 shards can keep "xap$SCHEMA_VERSION" on a separate FS. - if ($ibx->version == 1) { + if ($old && $ibx->version == 1) { if (defined $reshard) { warn "--reshard=$reshard ignored for v1 $ibx->{inboxdir}\n"; @@ -189,7 +191,7 @@ sub prepare_run { $tmp->{$old} = $wip; nodatacow_dir($wip->dirname); push @queue, [ $old, $wip ]; - } else { + } elsif ($old) { opendir my $dh, $old or die "Failed to opendir $old: $!\n"; my @old_shards; while (defined(my $dn = readdir($dh))) { @@ -255,7 +257,7 @@ sub run { PublicInbox::Admin::progress_prepare($opt ||= {}); defined(my $dir = $ibx->{inboxdir}) or die "no inboxdir defined\n"; -d $dir or die "inboxdir=$dir does not exist\n"; - check_compact() if $opt->{compact}; + check_compact() if $opt->{compact} && $ibx->search; my $reindex; # v1:{ from => $x40 }, v2:{ from => [ $x40, $x40, .. ] } } if (!$opt->{-coarse_lock}) { |