]> Sergey Matveev's repositories - public-inbox.git/commitdiff
v2writable: warn on unseen deleted files
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Mon, 26 Mar 2018 19:09:08 +0000 (19:09 +0000)
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Tue, 27 Mar 2018 02:34:25 +0000 (02:34 +0000)
It would be a bug to have deleted files marked but not
seen in our histories.

lib/PublicInbox/V2Writable.pm

index b04e6fbfe892dc1227b43c119f93713f38008a86..01ec98ac58c332655b0f31d38a1c551f784b21ae 100644 (file)
@@ -495,7 +495,7 @@ sub mark_deleted {
        my $mids = mids($mime->header_obj);
        my $cid = content_id($mime);
        foreach my $mid (@$mids) {
-               $D->{$mid.$cid} = 1;
+               $D->{"$mid\0$cid"} = 1;
        }
 }
 
@@ -513,7 +513,7 @@ sub reindex_oid {
        my $num = -1;
        my $del = 0;
        foreach my $mid (@$mids) {
-               $del += (delete $D->{$mid.$cid} || 0);
+               $del += (delete $D->{"$mid\0$cid"} || 0);
                my $n = $mm_tmp->num_for($mid);
                if (defined $n && $n > $num) {
                        $mid0 = $mid;
@@ -633,6 +633,14 @@ sub reindex {
        }
        my ($min, $max) = $mm_tmp->minmax;
        defined $max and die "leftover article numbers at $min..$max\n";
+       my @d = sort keys %$D;
+       if (@d) {
+               warn "BUG: ", scalar(@d)," unseen deleted messages marked\n";
+               foreach (@d) {
+                       my ($mid, undef) = split(/\0/, $_, 2);
+                       warn "<$mid>\n";
+               }
+       }
 }
 
 1;