]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
codesearchidx: use {topdir} for consistency
authorEric Wong <e@80x24.org>
Wed, 8 Oct 2025 21:24:20 +0000 (21:24 +0000)
committerEric Wong <e@80x24.org>
Fri, 10 Oct 2025 01:12:53 +0000 (01:12 +0000)
There's no reason for the read-only CodeSearch and read-write
CodeSearchIdx to use different field names for referring to the
same thing.  Consistently use {topdir} since it's inspired by
ExtSearch{,Idx} and also matches the configuration knob.  This
will make sharing methods between CodeSearch and CodeSearchIdx
easier.

lib/PublicInbox/CodeSearchIdx.pm
lib/PublicInbox/Xapcmd.pm

index dbb0fe3a18a0abe078277b76dbe292d821ef7953..27464300c9b6c3d7c9edcabe6cf0dffdcf69c5fa 100644 (file)
@@ -141,7 +141,7 @@ sub new {
        $l eq 'basic' and die "E: indexlevel=basic not supported\n";
        my $self = bless {
                xpfx => "$dir/cidx".  PublicInbox::CodeSearch::CIDX_SCHEMA_VER,
-               cidx_dir => $dir,
+               topdir => $dir,
                creat => 1, # TODO: get rid of this, should be implicit
                transact_bytes => 0, # for checkpoint
                total_bytes => 0, # for lock_release
@@ -723,7 +723,7 @@ sub load_existing ($) { # for -u/--update
        if ($self->{-opt}->{update} || $self->{-opt}->{prune}) {
                local $self->{xdb};
                $self->xdb or
-                       die "E: $self->{cidx_dir} non-existent for --update\n";
+                       die "E: $self->{topdir} non-existent for --update\n";
                my @cur = grep {
                        if (-e $_) {
                                1;
@@ -736,7 +736,7 @@ sub load_existing ($) { # for -u/--update
                        warn "W: the following repos no longer exist:\n",
                                (map { "W:\t$_\n" } @GIT_DIR_GONE),
                                "W: use --prune to remove them from ",
-                               $self->{cidx_dir}, "\n";
+                               $self->{topdir}, "\n";
                }
                push @$dirs, @cur;
        }
@@ -749,7 +749,7 @@ sub shard_usr1 { $TXN_BYTES = -1 }
 
 sub cidx_init ($) {
        my ($self) = @_;
-       my $dir = $self->{cidx_dir};
+       my $dir = $self->{topdir};
        unless (-d $dir) {
                warn "# creating $dir\n" if !$self->{-opt}->{quiet};
                File::Path::mkpath($dir);
@@ -869,12 +869,12 @@ sub prep_umask ($) {
                local $self->{git} =
                        PublicInbox::Git->new($self->{git_dirs}->[0]);
                $self->with_umask;
-       } elsif (-d $self->{cidx_dir}) { # respect existing perms
+       } elsif (-d $self->{topdir}) { # respect existing perms
                my @st = stat(_);
                my $um = (~$st[2] & 0777);
                $self->{umask} = $um; # for SearchIdx->with_umask
                umask == $um or progress($self, 'using umask from ',
-                                               $self->{cidx_dir}, ': ',
+                                               $self->{topdir}, ': ',
                                                sprintf('0%03o', $um));
                on_destroy \&CORE::umask, umask($um);
        } else {
@@ -1346,7 +1346,7 @@ sub cidx_run { # main entry point
                my $c = canonpath $d;
                next if $c eq $d;
                $cwarn = warn <<EOM if !$cwarn;
-E: BUG? paths in $self->{cidx_dir} not canonicalized:
+E: BUG? paths in $self->{topdir} not canonicalized:
 EOM
                warn "E: $d => $c\n";
                $d = $c;
index 7de71ee39262ae669d3ba773f19a7986a381e965..3fdadecceae757ec46c4249fd67e6b408573607c 100644 (file)
@@ -273,7 +273,7 @@ sub run {
        my ($ibx, $task, $opt) = @_; # task = 'cpdb' or 'compact'
        PublicInbox::Admin::progress_prepare($opt ||= {});
        my $dir;
-       for my $fld (qw(inboxdir topdir cidx_dir)) {
+       for my $fld (qw(inboxdir topdir)) {
                my $d = $ibx->{$fld} // next;
                -d $d or die "$fld=$d does not exist\n";
                $dir = $d;