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 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::progress_prepare($opt);
30 require PublicInbox::InboxWritable;
31 require PublicInbox::Xapcmd;
32 my $cfg = PublicInbox::Config->new;
33 my ($ibxs, $eidxs) = PublicInbox::Admin::resolve_inboxes(\@ARGV, $opt, $cfg);
34 unless ($ibxs) { print STDERR $help; exit 1 }
35 for my $ibx (@$ibxs) {
36 $ibx = PublicInbox::InboxWritable->new($ibx);
37 PublicInbox::Xapcmd::run($ibx, 'compact', $opt);
39 for my $eidx (@$eidxs) {
40 PublicInbox::Xapcmd::run($eidx, 'compact', $opt);