1 # Copyright (C) 2019 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 # common stuff between -edit, -purge (and maybe -learn in the future)
5 package PublicInbox::AdminEdit;
8 use PublicInbox::Admin;
9 our @OPT = qw(all force|f verbose|v!);
11 sub check_editable ($) {
14 foreach my $ibx (@$ibxs) {
15 my $lvl = $ibx->{indexlevel};
17 PublicInbox::Admin::indexlevel_ok_or_die($lvl);
21 # Undefined indexlevel, so `full'...
22 # Search::Xapian exists and the DB can be read, at least, fine
23 $ibx->search and next;
25 # it's possible for a Xapian directory to exist,
26 # but Search::Xapian to go missing/broken.
27 # Make sure it's purged in that case:
28 $ibx->over or die "no over.sqlite3 in $ibx->{mainrepo}\n";
30 # $ibx->{search} is populated by $ibx->over call
31 my $xdir_ro = $ibx->{search}->xdir(1);
33 foreach my $part (<$xdir_ro/*>) {
34 if (-d $part && $part =~ m!/[0-9]+\z!) {
36 $bytes += -s $_ foreach glob("$part/*");
41 PublicInbox::Admin::require_or_die('-search');
43 # somebody could "rm -r" all the Xapian directories;
44 # let them purge the overview, at least
45 $ibx->{indexlevel} ||= 'basic';