about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiImport.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-09-21 07:41:50 +0000
committerEric Wong <e@80x24.org>2021-09-21 19:18:35 +0000
commit8eaa877179910dce156179e9025d1e0df34089d8 (patch)
tree989189ccfd54d820144ce9593a9694fa18522d67 /lib/PublicInbox/LeiImport.pm
parent0c385e6500f26babc47a0768b730ea38e290a5f5 (diff)
downloadpublic-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/LeiImport.pm')
-rw-r--r--lib/PublicInbox/LeiImport.pm8
1 files changed, 6 insertions, 2 deletions
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;