diff options
author | Eric Wong <e@80x24.org> | 2021-09-21 07:41:50 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-09-21 19:18:35 +0000 |
commit | 8eaa877179910dce156179e9025d1e0df34089d8 (patch) | |
tree | 989189ccfd54d820144ce9593a9694fa18522d67 /lib/PublicInbox/LeiImportKw.pm | |
parent | 0c385e6500f26babc47a0768b730ea38e290a5f5 (diff) | |
download | public-inbox-8eaa877179910dce156179e9025d1e0df34089d8.tar.gz |
NNTP servers, IMAP servers, and various MUAs may recycle "unique" identifiers due to software bugs or careless BOFHs. Warn about them, but always be prepared to account for them.
Diffstat (limited to 'lib/PublicInbox/LeiImportKw.pm')
-rw-r--r-- | lib/PublicInbox/LeiImportKw.pm | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/PublicInbox/LeiImportKw.pm b/lib/PublicInbox/LeiImportKw.pm index 379101c2..21c93515 100644 --- a/lib/PublicInbox/LeiImportKw.pm +++ b/lib/PublicInbox/LeiImportKw.pm @@ -34,11 +34,15 @@ sub ipc_atfork_child { sub ck_update_kw { # via wq_io_do my ($self, $url, $uid, $kw) = @_; - my $oidbin = $self->{-lms_ro}->imap_oidbin($url, $uid) // return; - my @docids = $self->{over}->oidbin_exists($oidbin) or return; + my @oidbin = $self->{-lms_ro}->num_oidbin($url, $uid); + my $uid_url = "$url/;UID=$uid"; + @oidbin > 1 and $self->{lei}->err("W: $uid_url not unique:\n", + map { "\t".unpack('H*', $_)."\n" } @oidbin); + my %seen; + my @docids = sort { $a <=> $b } grep { !$seen{$_}++ } + map { $self->{over}->oidbin_exists($_) } @oidbin; $self->{lse}->kw_changed(undef, $kw, \@docids) or return; - $self->{verbose} and - $self->{lei}->qerr('# '.unpack('H*', $oidbin)." => @$kw\n"); + $self->{verbose} and $self->{lei}->qerr("# $uid_url => @$kw\n"); $self->{sto}->wq_do('set_eml_vmd', undef, { kw => $kw }, \@docids); } |