From 6cdb84af2c75b3c66a35c8c4973f455da15dd0a4 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 14 Dec 2020 11:42:40 +0000 Subject: lei_store: local storage for Local Email Interface Still unstable, this builds off the equally unstable extindex :P This will be used for caching/memoization of traditional mail stores (IMAP, Maildir, etc) while providing indexing via Xapian, along with compression, and checksumming from git. Most notably, this adds the ability to add/remove per-message keywords (draft, seen, flagged, answered) as described in the JMAP specification (RFC 8621 section 4.1.1). We'll use `.' (a single period) as an $eidx_key since it's an invalid {inboxdir} or {newsgroup} name. --- lib/PublicInbox/SearchIdxShard.pm | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'lib/PublicInbox/SearchIdxShard.pm') diff --git a/lib/PublicInbox/SearchIdxShard.pm b/lib/PublicInbox/SearchIdxShard.pm index 2e654769..87b0bad6 100644 --- a/lib/PublicInbox/SearchIdxShard.pm +++ b/lib/PublicInbox/SearchIdxShard.pm @@ -89,6 +89,12 @@ sub shard_worker_loop ($$$$$) { my ($len, $docid, $eidx_key) = split(/ /, $line, 3); $self->remove_eidx_info($docid, $eidx_key, eml($r, $len)); + } elsif ($line =~ s/\A=K (\d+) //) { + $self->set_keywords($1 + 0, split(/ /, $line)); + } elsif ($line =~ s/\A-K (\d+) //) { + $self->remove_keywords($1 + 0, split(/ /, $line)); + } elsif ($line =~ s/\A\+K (\d+) //) { + $self->add_keywords($1 + 0, split(/ /, $line)); } elsif ($line =~ s/\AO ([^\n]+)//) { my $over_fn = $1; $over_fn =~ tr/\0/\n/; @@ -210,6 +216,33 @@ sub shard_remove { } } +sub shard_set_keywords { + my ($self, $docid, @kw) = @_; + if (my $w = $self->{w}) { # triggers remove_by_docid in a shard child + print $w "=K $docid @kw\n" or die "failed to write: $!"; + } else { # same process + $self->set_keywords($docid, @kw); + } +} + +sub shard_remove_keywords { + my ($self, $docid, @kw) = @_; + if (my $w = $self->{w}) { # triggers remove_by_docid in a shard child + print $w "-K $docid @kw\n" or die "failed to write: $!"; + } else { # same process + $self->remove_keywords($docid, @kw); + } +} + +sub shard_add_keywords { + my ($self, $docid, @kw) = @_; + if (my $w = $self->{w}) { # triggers remove_by_docid in a shard child + print $w "+K $docid @kw\n" or die "failed to write: $!"; + } else { # same process + $self->add_keywords($docid, @kw); + } +} + sub shard_over_check { my ($self, $over) = @_; if (my $w = $self->{w}) { # triggers remove_by_docid in a shard child -- cgit v1.2.3-24-ge0c7