]> Sergey Matveev's repositories - public-inbox.git/commitdiff
searchidx: do not create empty Xapian partitions for basic
authorEric Wong <e@80x24.org>
Wed, 15 May 2019 01:18:10 +0000 (01:18 +0000)
committerEric Wong <e@80x24.org>
Wed, 15 May 2019 05:54:18 +0000 (05:54 +0000)
No point in leaving a mess of empty directories when Xapian
doesn't load.

lib/PublicInbox/SearchIdx.pm
t/indexlevels-mirror.t

index 135b5eb9b0f1768abbe0b0c115e6fbaf2e9cef39..f96f0d0378715747d4b9be1ebe55965e5b209857 100644 (file)
@@ -110,7 +110,12 @@ sub _xdb_acquire {
        if ($self->{creat}) {
                require File::Path;
                $self->lock_acquire;
-               File::Path::mkpath($dir);
+
+               # don't create empty Xapian directories if we don't need Xapian
+               my $is_part = defined($self->{partition});
+               if (!$is_part || ($is_part && need_xapian($self))) {
+                       File::Path::mkpath($dir);
+               }
        }
        return unless defined $flag;
        $self->{xdb} = Search::Xapian::WritableDatabase->new($dir, $flag);
index cac7050bdca3840c484cc778c3d5484e892652f3..3dd432382672344bb4458acb0c2ef95c03160fbd 100644 (file)
@@ -116,6 +116,11 @@ sub import_index_incremental {
        is($nr, 1, '2nd message gone from mirror');
        is_deeply([map { $_->{mid} } @$msgs], ['m@1'],
                'message unavailable in mirror');
+
+       if ($v == 2 && $level eq 'basic') {
+               is_deeply([glob("$ibx->{mainrepo}/xap*/?/")], [],
+                        'no Xapian partition directories for v2 basic');
+       }
 }
 
 # we can probably cull some other tests and put full/medium tests, here