diff options
author | Eric Wong <e@80x24.org> | 2021-01-19 09:34:34 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-01-21 03:29:13 +0000 |
commit | 934b7431d93e6e49920e407c02653edad06987d6 (patch) | |
tree | 5792adf8d6bc812c1b66fa84d88994d466a8bfe4 /lib/PublicInbox | |
parent | 90e3d8101429793b80ac75d4f87ec058f77e5b1d (diff) | |
download | public-inbox-934b7431d93e6e49920e407c02653edad06987d6.tar.gz |
Because user errors happen...
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r-- | lib/PublicInbox/LeiOverview.pm | 3 | ||||
-rw-r--r-- | lib/PublicInbox/LeiToMail.pm | 6 | ||||
-rw-r--r-- | lib/PublicInbox/LeiXSearch.pm | 9 |
3 files changed, 15 insertions, 3 deletions
diff --git a/lib/PublicInbox/LeiOverview.pm b/lib/PublicInbox/LeiOverview.pm index 8781259a..a7021b03 100644 --- a/lib/PublicInbox/LeiOverview.pm +++ b/lib/PublicInbox/LeiOverview.pm @@ -82,7 +82,8 @@ sub new { if (!$json) { # default to the cheapest sort since MUA usually resorts $lei->{opt}->{'sort'} //= 'docid' if $dst ne '/dev/stdout'; - $lei->{l2m} = PublicInbox::LeiToMail->new($lei); + $lei->{l2m} = eval { PublicInbox::LeiToMail->new($lei) }; + return $lei->fail($@) if $@; } $lei->{dedupe} //= PublicInbox::LeiDedupe->new($lei); $self; diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm index a6e517ea..49b5c8ab 100644 --- a/lib/PublicInbox/LeiToMail.pm +++ b/lib/PublicInbox/LeiToMail.pm @@ -339,8 +339,12 @@ sub new { my $self = bless {}, $cls; if ($fmt eq 'maildir') { $self->{base_type} = 'maildir'; + -e $dst && !-d _ and die + "$dst exists and is not a directory\n"; $lei->{ovv}->{dst} = $dst .= '/' if substr($dst, -1) ne '/'; } elsif (substr($fmt, 0, 4) eq 'mbox') { + -e $dst && !-f _ && !-p _ and die + "$dst exists and is not a regular file\n"; $self->can("eml2$fmt") or die "bad mbox --format=$fmt\n"; $self->{base_type} = 'mbox'; } else { @@ -374,7 +378,7 @@ sub _post_augment_maildir { my $d = $dst.$x; next if -d $d; require File::Path; - File::Path::mkpath($d) or die "mkpath($d): $!"; + File::Path::mkpath($d); -d $d or die "$d is not a directory"; } } diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm index 002791c2..fa37543f 100644 --- a/lib/PublicInbox/LeiXSearch.pm +++ b/lib/PublicInbox/LeiXSearch.pm @@ -201,7 +201,14 @@ sub query_done { # EOF callback sub do_post_augment { my ($lei, $zpipe, $au_done) = @_; my $l2m = $lei->{l2m} or die 'BUG: no {l2m}'; - $l2m->post_augment($lei, $zpipe); + eval { $l2m->post_augment($lei, $zpipe) }; + if (my $err = $@) { + if (my $lxs = delete $lei->{lxs}) { + $lxs->wq_kill; + $lxs->wq_close; + } + $lei->fail("$err"); + } close $au_done; # triggers wait_startq } |