]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiStore.pm
lei: All Local Externals: bare git dir for alternates
[public-inbox.git] / lib / PublicInbox / LeiStore.pm
index 10fa9c5489f62d999cd064f918eb0318d0cb83db..c1abc288bfcb46f539f0a689fac33c53030aa065 100644 (file)
@@ -129,46 +129,38 @@ sub _docids_for ($$) {
        sort { $a <=> $b } values %docids;
 }
 
-sub set_eml_keywords {
-       my ($self, $eml, @kw) = @_;
+sub set_eml_vmd {
+       my ($self, $eml, $vmd) = @_;
        my $eidx = eidx_init($self);
        my @docids = _docids_for($self, $eml);
        for my $docid (@docids) {
-               $eidx->idx_shard($docid)->ipc_do('set_keywords', $docid, @kw);
+               $eidx->idx_shard($docid)->ipc_do('set_vmd', $docid, $vmd);
        }
        \@docids;
 }
 
-sub add_eml_keywords {
-       my ($self, $eml, @kw) = @_;
+sub add_eml_vmd {
+       my ($self, $eml, $vmd) = @_;
        my $eidx = eidx_init($self);
        my @docids = _docids_for($self, $eml);
        for my $docid (@docids) {
-               $eidx->idx_shard($docid)->ipc_do('add_keywords', $docid, @kw);
+               $eidx->idx_shard($docid)->ipc_do('add_vmd', $docid, $vmd);
        }
        \@docids;
 }
 
-sub remove_eml_keywords {
-       my ($self, $eml, @kw) = @_;
+sub remove_eml_vmd {
+       my ($self, $eml, $vmd) = @_;
        my $eidx = eidx_init($self);
        my @docids = _docids_for($self, $eml);
        for my $docid (@docids) {
-               $eidx->idx_shard($docid)->ipc_do('remove_keywords', $docid, @kw)
+               $eidx->idx_shard($docid)->ipc_do('remove_vmd', $docid, $vmd);
        }
        \@docids;
 }
 
-# TODO: move this to MdirReader, maybe...
-# cf: https://cr.yp.to/proto/maildir.html
-my %c2kw = ('D' => 'draft', F => 'flagged', R => 'answered', S => 'seen');
-sub maildir_keywords {
-       $_[-1] =~ /:2,([A-Z]+)\z/i ?
-               sort(map { $c2kw{$_} // () } split(//, $1)) : ();
-}
-
 sub add_eml {
-       my ($self, $eml, @kw) = @_;
+       my ($self, $eml, $vmd) = @_;
        my $im = $self->importer; # may create new epoch
        my $eidx = eidx_init($self); # writes ALL.git/objects/info/alternates
        my $oidx = $eidx->{oidx};
@@ -182,7 +174,7 @@ sub add_eml {
                        $oidx->add_xref3($docid, -1, $smsg->{blob}, '.');
                        # add_eidx_info for List-Id
                        $idx->ipc_do('add_eidx_info', $docid, '.', $eml);
-                       $idx->ipc_do('add_keywords', $docid, @kw) if @kw;
+                       $idx->ipc_do('add_vmd', $docid, $vmd) if $vmd;
                }
                \@docids;
        } else {
@@ -191,14 +183,14 @@ sub add_eml {
                $oidx->add_xref3($smsg->{num}, -1, $smsg->{blob}, '.');
                my $idx = $eidx->idx_shard($smsg->{num});
                $idx->index_eml($eml, $smsg);
-               $idx->ipc_do('add_keywords', $smsg->{num}, @kw) if @kw;
+               $idx->ipc_do('add_vmd', $smsg->{num}, $vmd ) if $vmd;
                $smsg;
        }
 }
 
 sub set_eml {
-       my ($self, $eml, @kw) = @_;
-       add_eml($self, $eml, @kw) // set_eml_keywords($self, $eml, @kw);
+       my ($self, $eml, $vmd) = @_;
+       add_eml($self, $eml, $vmd) // set_eml_vmd($self, $eml, $vmd);
 }
 
 sub add_eml_maybe {
@@ -215,7 +207,7 @@ sub set_xkw {
        if ($lxs->xids_for($eml, 1)) { # is it in a local external?
                # TODO: index keywords only
        } else {
-               set_eml($self, $eml, @$kw);
+               set_eml($self, $eml, { kw => $kw });
        }
 }
 
@@ -259,24 +251,25 @@ sub refresh_local_externals {
                for my $loc (@loc) { # locals only
                        $lxs->prepare_external($loc) if -d $loc;
                }
+               $self->{lei}->ale->refresh_externals($lxs);
+               $lxs->{git} = $self->{lei}->ale->git;
                $self->{lxs_all_local} = $lxs;
                $self->{cur_cfg} = $cfg;
        }
-       ($lxs->{git_tmp} //= $lxs->git_tmp)->{git_dir};
 }
 
 sub write_prepare {
        my ($self, $lei) = @_;
        unless ($self->{-ipc_req}) {
                require PublicInbox::LeiXSearch;
-               $self->ipc_lock_init;
+               $self->ipc_lock_init($lei->store_path . '/ipc.lock');
                # Mail we import into lei are private, so headers filtered out
                # by -mda for public mail are not appropriate
                local @PublicInbox::MDA::BAD_HEADERS = ();
                $self->ipc_worker_spawn('lei_store', $lei->oldset,
                                        { lei => $lei });
        }
-       $lei->{all_ext_git_dir} = $self->ipc_do('refresh_local_externals');
+       my $wait = $self->ipc_do('refresh_local_externals');
        $lei->{sto} = $self;
 }