]> Sergey Matveev's repositories - public-inbox.git/commitdiff
searchidx: die on cat-file failures
authorEric Wong <e@yhbt.net>
Sat, 18 Apr 2020 03:38:47 +0000 (03:38 +0000)
committerEric Wong <e@yhbt.net>
Sun, 19 Apr 2020 08:51:20 +0000 (08:51 +0000)
We always use the object ID from "git <log|rev-list>" for
retrieving blobs, so fail loudly if the git repository is
corrupt instead of silently continuing.

lib/PublicInbox/SearchIdx.pm

index 05689941e0b80bdaed9c6caca89c18846f57c5ea..d1290dc208e37eb7689deff009da165fa5234ed1 100644 (file)
@@ -551,13 +551,11 @@ sub unindex_both {
 
 sub do_cat_mail {
        my ($git, $blob, $sizeref) = @_;
-       my $mime = eval {
-               my $str = $git->cat_file($blob, $sizeref);
-               # fixup bugs from import:
-               $$str =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s;
-               PublicInbox::MIME->new($str);
-       };
-       $@ ? undef : $mime;
+       my $str = $git->cat_file($blob, $sizeref) or
+               die "BUG: $blob not found in $git->{git_dir}";
+       # fixup bugs from import:
+       $$str =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s;
+       PublicInbox::MIME->new($str);
 }
 
 # called by public-inbox-index
@@ -602,7 +600,7 @@ sub read_log {
                                }
                                next;
                        }
-                       my $mime = do_cat_mail($git, $blob, \$bytes) or next;
+                       my $mime = do_cat_mail($git, $blob, \$bytes);
                        my $smsg = bless {}, 'PublicInbox::Smsg';
                        batch_adjust(\$max, $bytes, $batch_cb, $latest, ++$nr);
                        $smsg->{blob} = $blob;
@@ -623,7 +621,7 @@ sub read_log {
        close($log) or die "git log failed: \$?=$?";
        # get the leftovers
        foreach my $blob (keys %D) {
-               my $mime = do_cat_mail($git, $blob, \$bytes) or next;
+               my $mime = do_cat_mail($git, $blob, \$bytes);
                $del_cb->($self, $mime);
        }
        $batch_cb->($nr, $latest, $newest);