X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=script%2Fpublic-inbox-compact;h=5c681466fa153190b9e5d2110a80a6720d1dbbd8;hb=2fc67a18b7ccd75ea6eb945f18203cbf4bcf228f;hp=4aa6273dc2435272c537c2ebceb27b4eefbeef5a;hpb=7e56f47848127b65979c786595244a552b164b3d;p=public-inbox.git
diff --git a/script/public-inbox-compact b/script/public-inbox-compact
index 4aa6273d..5c681466 100755
--- a/script/public-inbox-compact
+++ b/script/public-inbox-compact
@@ -1,35 +1,19 @@
#!/usr/bin/perl -w
-# Copyright (C) 2018 all contributors
+# Copyright (C) 2018-2020 all contributors
# License: AGPL-3.0+
use strict;
use warnings;
use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev);
-use PublicInbox::Search;
-use PublicInbox::Config;
use PublicInbox::InboxWritable;
-use Cwd 'abs_path';
use PublicInbox::Xapcmd;
-my $usage = "Usage: public-inbox-compact REPO_DIR\n";
-my $dir = shift or die $usage;
-my $config = eval { PublicInbox::Config->new };
-my $ibx;
-$dir = abs_path($dir);
-if ($config) {
- $config->each_inbox(sub {
- $ibx = $_[0] if abs_path($_[0]->{mainrepo}) eq $dir
- });
+use PublicInbox::Admin;
+PublicInbox::Admin::require_or_die('-index');
+my $usage = "Usage: public-inbox-compact INBOX_DIR\n";
+my $opt = { compact => 1, -coarse_lock => 1 };
+GetOptions($opt, @PublicInbox::Xapcmd::COMPACT_OPT) or
+ die "bad command-line args\n$usage";
+my @ibxs = PublicInbox::Admin::resolve_inboxes(\@ARGV) or die $usage;
+foreach (@ibxs) {
+ my $ibx = PublicInbox::InboxWritable->new($_);
+ PublicInbox::Xapcmd::run($ibx, 'compact', $opt);
}
-unless ($ibx) {
- warn "W: $dir not configured in ".
- PublicInbox::Config::default_file() . "\n";
- $ibx = {
- mainrepo => $dir,
- name => 'ignored',
- address => [ 'old@example.com' ],
- };
- $ibx = PublicInbox::Inbox->new($ibx);
-}
-$ibx = PublicInbox::InboxWritable->new($ibx);
-
-# we rely on --no-renumber to keep docids synched to NNTP
-PublicInbox::Xapcmd::run($ibx, [qw(xapian-compact --no-renumber)]);