diff options
author | Eric Wong <e@80x24.org> | 2021-03-23 11:02:17 +0600 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-03-24 01:33:26 +0000 |
commit | 5be0cb101bab44167a78af7a2d167f254c95bdb3 (patch) | |
tree | 133ed291d5caca9819d95217b0b512990257d225 /lib/PublicInbox/LeiStore.pm | |
parent | e7d13d7bc4a7b1e990602e796b7c2acbddb99a7b (diff) | |
download | public-inbox-5be0cb101bab44167a78af7a2d167f254c95bdb3.tar.gz |
Only tested for keywords and labels with file inputs, so far; but it seems to do what it needs to do. There's a bit more redundant code than I'd like, and more opportunities for code sharing in the future "lei import" will be expanded to support +kw:$KEYWORD and +L:$LABEL in the future.
Diffstat (limited to 'lib/PublicInbox/LeiStore.pm')
-rw-r--r-- | lib/PublicInbox/LeiStore.pm | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/PublicInbox/LeiStore.pm b/lib/PublicInbox/LeiStore.pm index b390b318..b5d43b7e 100644 --- a/lib/PublicInbox/LeiStore.pm +++ b/lib/PublicInbox/LeiStore.pm @@ -228,12 +228,30 @@ sub set_eml { set_eml_vmd($self, $eml, $vmd); } +sub update_xvmd { + my ($self, $xoids, $vmd_mod) = @_; + my $eidx = eidx_init($self); + my $oidx = $eidx->{oidx}; + my %seen; + for my $oid (keys %$xoids) { + my @docids = $oidx->blob_exists($oid) or next; + scalar(@docids) > 1 and + warn "W: $oid indexed as multiple docids: @docids\n"; + for my $docid (@docids) { + next if $seen{$docid}++; + my $idx = $eidx->idx_shard($docid); + $idx->ipc_do('update_vmd', $docid, $vmd_mod); + } + } +} + # set or update keywords for external message, called via ipc_do sub set_xvmd { my ($self, $xoids, $eml, $vmd) = @_; my $eidx = eidx_init($self); my $oidx = $eidx->{oidx}; + my %seen; # see if we can just update existing docs for my $oid (keys %$xoids) { @@ -241,6 +259,7 @@ sub set_xvmd { scalar(@docids) > 1 and warn "W: $oid indexed as multiple docids: @docids\n"; for my $docid (@docids) { + next if $seen{$docid}++; my $idx = $eidx->idx_shard($docid); $idx->ipc_do('set_vmd', $docid, $vmd); } |