diff options
author | Eric Wong <e@yhbt.net> | 2020-03-28 00:56:04 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-03-29 23:28:30 +0000 |
commit | b5ddcb3352ef31aeb03b4c4cbb04af3de34a4c4f (patch) | |
tree | 6e1a63adf6d5a28add5edf0bd74ca8bcaff2c00f /lib/PublicInbox | |
parent | 8e1ec8836dabc58dfc0115b36ed440b4371b70d7 (diff) | |
download | public-inbox-b5ddcb3352ef31aeb03b4c4cbb04af3de34a4c4f.tar.gz |
It's more convenient to specify `-c' / `--compact' on the command-line when reindexing than it is to invoke public-inbox-compact(1) separately. This is especially convenient in low-space situations when public-inbox-index is operating on multiple inboxes sequentially, as compaction can happen immediately after indexing each inbox, instead of waiting until all inboxes are indexed.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r-- | lib/PublicInbox/InboxWritable.pm | 1 | ||||
-rw-r--r-- | lib/PublicInbox/Xapcmd.pm | 4 |
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/PublicInbox/InboxWritable.pm b/lib/PublicInbox/InboxWritable.pm index e684f546..ce979ea2 100644 --- a/lib/PublicInbox/InboxWritable.pm +++ b/lib/PublicInbox/InboxWritable.pm @@ -19,6 +19,7 @@ use constant { sub new { my ($class, $ibx, $creat_opt) = @_; + return $ibx if ref($ibx) eq $class; my $self = bless $ibx, $class; # TODO: maybe stop supporting this diff --git a/lib/PublicInbox/Xapcmd.pm b/lib/PublicInbox/Xapcmd.pm index 7414c9b6..8e2b9063 100644 --- a/lib/PublicInbox/Xapcmd.pm +++ b/lib/PublicInbox/Xapcmd.pm @@ -217,13 +217,15 @@ sub prepare_run { ($tmp, \@queue); } +sub check_compact () { runnable_or_die($XAPIAN_COMPACT) } + sub run { my ($ibx, $task, $opt) = @_; # task = 'cpdb' or 'compact' my $cb = \&${\"PublicInbox::Xapcmd::$task"}; 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"; - runnable_or_die($XAPIAN_COMPACT) if $opt->{compact}; + check_compact() if $opt->{compact}; my $reindex; # v1:{ from => $x40 }, v2:{ from => [ $x40, $x40, .. ] } } if (!$opt->{-coarse_lock}) { |