From 8eaa877179910dce156179e9025d1e0df34089d8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 21 Sep 2021 07:41:50 +0000 Subject: lei_mail_sync: account for non-unique cases 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. --- lib/PublicInbox/LeiImport.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/PublicInbox/LeiImport.pm') diff --git a/lib/PublicInbox/LeiImport.pm b/lib/PublicInbox/LeiImport.pm index 40530914..3c30db8d 100644 --- a/lib/PublicInbox/LeiImport.pm +++ b/lib/PublicInbox/LeiImport.pm @@ -37,8 +37,12 @@ sub pmdir_cb { # called via wq_io_do from LeiPmdir->each_mdir_fn substr($folder, 0, 0) = 'maildir:'; # add prefix my $lse = $self->{lse} //= $self->{lei}->{sto}->search; my $lms = $self->{-lms_ro} //= $self->{lei}->lms; # may be 0 or undef - my $oidbin = $lms ? $lms->name_oidbin($folder, $bn) : undef; - my @docids = defined($oidbin) ? $lse->over->oidbin_exists($oidbin) : (); + my @oidbin = $lms ? $lms->name_oidbin($folder, $bn) : (); + @oidbin > 1 and $self->{lei}->err("W: $folder/*/$$bn not unique:\n", + map { "\t".unpack('H*', $_)."\n" } @oidbin); + my %seen; + my @docids = sort { $a <=> $b } grep { !$seen{$_}++ } + map { $lse->over->oidbin_exists($_) } @oidbin; my $vmd = $self->{-import_kw} ? { kw => $kw } : undef; if (scalar @docids) { $lse->kw_changed(undef, $kw, \@docids) or return; -- cgit v1.2.3-24-ge0c7