From: Eric Wong <e@yhbt.net>
To: meta@public-inbox.org
Subject: [PATCH 2/8] searchidx: die on cat-file failures
Date: Sat, 18 Apr 2020 03:38:47 +0000 [thread overview]
Message-ID: <20200418033853.9798-3-e@yhbt.net> (raw)
In-Reply-To: <20200418033853.9798-1-e@yhbt.net>
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 | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index 05689941..d1290dc2 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -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);
next prev parent reply other threads:[~2020-04-18 3:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-18 3:38 [PATCH 0/8] some small yak shaving things Eric Wong
2020-04-18 3:38 ` [PATCH 1/8] inboxwritable: mime_from_path: reuse in more places Eric Wong
2020-04-18 3:38 ` Eric Wong [this message]
2020-04-18 3:38 ` [PATCH 3/8] inbox: don't memoize missing description|cloneurl Eric Wong
2020-04-18 3:38 ` [PATCH 4/8] inbox: replace `eval {}' with `do {}' where appropriate Eric Wong
2020-04-18 3:38 ` [PATCH 5/8] favor `do {}' over `eval {}' for localized slurp Eric Wong
2020-04-18 3:38 ` [PATCH 6/8] wwwatomstream: move {emit_header} field to $self Eric Wong
2020-04-18 3:38 ` [PATCH 7/8] mbox: use per-message line-ending for From_ line Eric Wong
2020-04-18 3:38 ` [PATCH 8/8] reduce scope of mbox From_ line removal Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200418033853.9798-3-e@yhbt.net \
--to=e@yhbt.net \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).