]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei import: reduce writes to lei/store on IMAP sync
authorEric Wong <e@80x24.org>
Mon, 31 May 2021 10:20:06 +0000 (10:20 +0000)
committerEric Wong <e@80x24.org>
Tue, 1 Jun 2021 17:03:04 +0000 (17:03 +0000)
We don't need to write VMD changes to lei/store if local
keywords are unchanged.

lib/PublicInbox/LeiImport.pm
lib/PublicInbox/LeiSearch.pm
lib/PublicInbox/NetReader.pm

index f9a46ec58b5233b877b5ab01c084bbcd354c2a23..860a2c98ffeb9fea600abce5f6043277698847d3 100644 (file)
@@ -50,6 +50,7 @@ sub input_net_cb { # imap_each / nntp_each
        } elsif ($vmd) { # old message, kw only
                my $oid = $self->{-lms_ro}->imap_oid2($uri, $uid) // return;
                my @docids = $self->{lse}->over->blob_exists($oid) or return;
+               $self->{lse}->kw_changed(undef, $kw, \@docids) or return;
                my $lei = $self->{lei};
                $lei->qerr("# $oid => @$kw\n") if $lei->{opt}->{verbose};
                $self->{lei}->{sto}->ipc_do('set_eml_vmd', undef,
index b09d1e455d7495ca81e65c4d5ff52f321589fe26..d0963e928c6500402f8560f6e89515ce957d3f95 100644 (file)
@@ -133,9 +133,11 @@ sub xoids_for {
 # returns true if $eml is indexed by lei/store and keywords don't match
 sub kw_changed {
        my ($self, $eml, $new_kw_sorted, $docids) = @_;
-       my $xoids = xoids_for($self, $eml) // return;
-       $docids //= [];
-       @$docids = sort { $a <=> $b } values %$xoids;
+       if ($eml) {
+               my $xoids = xoids_for($self, $eml) // return;
+               $docids //= [];
+               @$docids = sort { $a <=> $b } values %$xoids;
+       }
        my $cur_kw = msg_keywords($self, $docids->[0]);
 
        # RFC 5550 sec 5.9 on the $Forwarded keyword states:
index b97444fded2870a28338534fd7aa1fef4fbfafdc..39a8f7fc90178de5d181634d99f6bbead1d0009d 100644 (file)
@@ -409,7 +409,7 @@ sub flags2kw ($$$$) {
                        warn "# unknown IMAP flag $f <$uri/;UID=$uid>\n";
                }
        }
-       @$kw = sort @$kw; # for all UI/UX purposes
+       @$kw = sort @$kw; # for LeiSearch->kw_changed and UI/UX purposes
        $kw;
 }