about summary refs log tree commit homepage
path: root/script/public-inbox-index
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-03-21 09:04:50 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-03-22 00:19:17 +0000
commit3a4394468b4a9affc38f8e0f56011adb72269ec2 (patch)
tree850d0f5c36d04b68c736a0f4a4f918c5dd3d1d41 /script/public-inbox-index
parentb41c5982647a8ecccbadf159381840d74d36248a (diff)
downloadpublic-inbox-3a4394468b4a9affc38f8e0f56011adb72269ec2.tar.gz
This still requires a msgmap.sqlite3 file to exist, but
it allows us to tweak Xapian indexing rules and reindex
the Xapian database online while -watch is running.
Diffstat (limited to 'script/public-inbox-index')
-rwxr-xr-xscript/public-inbox-index25
1 files changed, 20 insertions, 5 deletions
diff --git a/script/public-inbox-index b/script/public-inbox-index
index 1debbaac..cea35738 100755
--- a/script/public-inbox-index
+++ b/script/public-inbox-index
@@ -31,6 +31,9 @@ my @dirs;
 sub resolve_repo_dir {
         my ($cd) = @_;
         my $prefix = defined $cd ? $cd : './';
+        if (-d $prefix && -f "$prefix/inbox.lock") { # v2
+                return abs_path($prefix);
+        }
 
         my @cmd = qw(git rev-parse --git-dir);
         my $cmd = join(' ', @cmd);
@@ -75,14 +78,26 @@ foreach my $k (keys %$config) {
 }
 
 foreach my $dir (@dirs) {
+        if (!ref($dir) && -f "$dir/inbox.lock") { # v2
+                my $ibx = { mainrepo => $dir, name => 'unnamed' };
+                $dir = PublicInbox::Inbox->new($ibx);
+        }
         index_dir($dir);
 }
 
 sub index_dir {
-        my ($git_dir) = @_;
-        if (!ref $git_dir && ! -d $git_dir) {
-                die "$git_dir does not appear to be a git repository\n";
+        my ($repo) = @_;
+        if (!ref $repo && ! -d $repo) {
+                die "$repo does not appear to be an inbox repository\n";
+        }
+        if (ref($repo) && ($repo->{version} || 1) == 2) {
+                eval { require PublicInbox::V2Writable };
+                die "v2 requirements not met: $@\n" if $@;
+                my $v2w = PublicInbox::V2Writable->new($repo);
+                $v2w->reindex;
+                $v2w->done;
+        } else {
+                my $s = PublicInbox::SearchIdx->new($repo, 1);
+                $s->index_sync({ reindex => $reindex });
         }
-        my $s = PublicInbox::SearchIdx->new($git_dir, 1);
-        $s->index_sync({ reindex => $reindex });
 }