2 # Copyright (C) 2018-2021 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev);
7 my $opt = { compact => 1, -coarse_lock => 1, -eidx_ok => 1 };
8 my $help = <<EOF; # the following should fit w/o scrolling in 80x24 term:
9 usage: public-inbox-compact <INBOX_DIR|EXTINDEX_DIR>
11 Compact Xapian DBs in an inbox
15 --all index all configured inboxes
16 --jobs=NUM control parallelization
18 See public-inbox-compact(1) man page for full documentation.
20 GetOptions($opt, qw(all C=s@ help|h),
22 qw(jobs|j=i quiet|q blocksize|b=s no-full|n fuller|F),
24 if ($opt->{help}) { print $help; exit 0 };
26 require PublicInbox::Admin;
27 PublicInbox::Admin::require_or_die('-index');
28 PublicInbox::Admin::do_chdir(delete $opt->{C});
29 PublicInbox::Admin::progress_prepare($opt);
31 require PublicInbox::InboxWritable;
32 require PublicInbox::Xapcmd;
33 my $cfg = PublicInbox::Config->new;
34 my ($ibxs, $eidxs) = PublicInbox::Admin::resolve_inboxes(\@ARGV, $opt, $cfg);
35 unless ($ibxs) { print STDERR $help; exit 1 }
36 for my $ibx (@$ibxs) {
37 $ibx = PublicInbox::InboxWritable->new($ibx);
38 PublicInbox::Xapcmd::run($ibx, 'compact', $opt);
40 for my $eidx (@$eidxs) {
41 PublicInbox::Xapcmd::run($eidx, 'compact', $opt);