diff options
author | Eric Wong <e@80x24.org> | 2021-04-29 09:46:19 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-04-30 06:41:36 +0000 |
commit | 90155b72ccd38d51415f12547e39c4d65c469fe1 (patch) | |
tree | 570c61708a093f24dcba9f05d415c22a2a2cbc23 /lib | |
parent | 923e09d84e8eaa612c85f6d5ec57c3742390bebc (diff) | |
download | public-inbox-90155b72ccd38d51415f12547e39c4d65c469fe1.tar.gz |
Specifying a UIDVALIDITY value allows the user to enforce a strict match and force failure. This necessitated changes to NetReader to allow die() and make error reporting more suitable for CLI usage rather than daemonized usage of -watch.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PublicInbox/LeiInput.pm | 10 | ||||
-rw-r--r-- | lib/PublicInbox/NetReader.pm | 7 |
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/PublicInbox/LeiInput.pm b/lib/PublicInbox/LeiInput.pm index ce675f40..277ad88d 100644 --- a/lib/PublicInbox/LeiInput.pm +++ b/lib/PublicInbox/LeiInput.pm @@ -293,6 +293,7 @@ $input is `eml', not --in-format=$in_fmt $lei->err("# --sync is not supported for: @{$sync->{no}}"); } if ($net) { + $net->{-can_die} = 1; if (my $err = $net->errors) { return $lei->fail($err); } @@ -306,10 +307,17 @@ $input is `eml', not --in-format=$in_fmt sub process_inputs { my ($self) = @_; + my $err; for my $input (@{$self->{inputs}}) { - $self->input_path_url($input); + eval { $self->input_path_url($input) }; + next unless $@; + $err = "$input: $@"; + last; } + # always commit first, even on error partial work is acceptable for + # lei <import|tag|convert> my $wait = $self->{lei}->{sto}->ipc_do('done') if $self->{lei}->{sto}; + $self->{lei}->fail($err) if $err; } sub input_only_atfork_child { diff --git a/lib/PublicInbox/NetReader.pm b/lib/PublicInbox/NetReader.pm index 81d25ead..3fc37b10 100644 --- a/lib/PublicInbox/NetReader.pm +++ b/lib/PublicInbox/NetReader.pm @@ -407,6 +407,11 @@ sub _imap_fetch_all ($$$) { return "E: $orig_uri cannot get UIDVALIDITY"; $r_uidnext //= $mic->uidnext($mbx) // return "E: $orig_uri cannot get UIDNEXT"; + my $expect = $orig_uri->uidvalidity // $r_uidval; + return <<EOF if $expect != $r_uidval; +E: $orig_uri UIDVALIDITY mismatch (got $r_uidval) +EOF + my $uri = $orig_uri->clone; my ($itrk, $l_uid, $l_uidval) = _itrk_last($self, $uri, $r_uidval); return <<EOF if $l_uidval != $r_uidval; @@ -520,6 +525,7 @@ sub imap_each { } else { $err = "E: <$uri> not connected: $!"; } + die $err if $err && $self->{-can_die}; warn $err if $err; $mic; } @@ -620,6 +626,7 @@ sub nntp_each { } else { $err = "E: <$uri> not connected: $!"; } + die $err if $err && $self->{-can_die}; warn $err if $err; $nn; } |