$rand = '';
do {
$final = $dst.$rand.$common.':2,'.$sfx;
- } while (!link($tmp, $final) && $! == EEXIST &&
+ } while (!($ok = link($tmp, $final)) && $! == EEXIST &&
($rand = _rand.','));
+ die "link($tmp, $final): $!" unless $ok;
unlink($tmp) or warn "W: failed to unlink $tmp: $!\n";
} else {
my $err = "Error writing $smsg->{blob} to $dst: $!\n";
require PublicInbox::MboxReader if $lei->{opt}->{augment};
(-d $dst || (-e _ && !-w _)) and die
"$dst exists and is not a writable file\n";
- $self->can("eml2$fmt") or die "bad mbox --format=$fmt\n";
+ $self->can("eml2$fmt") or die "bad mbox format: $fmt\n";
$self->{base_type} = 'mbox';
} else {
die "bad mail --format=$fmt\n";
}
}
-sub _post_augment_maildir {} # noop
-
sub _pre_augment_mbox {
my ($self, $lei) = @_;
my $dst = $lei->{ovv}->{dst};
sub pre_augment { # fast (1 disk seek), runs in same process as post_augment
my ($self, $lei) = @_;
# _pre_augment_maildir, _pre_augment_mbox
- my $m = "_pre_augment_$self->{base_type}";
- $self->$m($lei);
+ my $m = $self->can("_pre_augment_$self->{base_type}") or return;
+ $m->($self, $lei);
}
sub do_augment { # slow, runs in wq worker
# fast (spawn compressor or mkdir), runs in same process as pre_augment
sub post_augment {
my ($self, $lei, @args) = @_;
- # _post_augment_maildir, _post_augment_mbox
- my $m = "_post_augment_$self->{base_type}";
- $self->$m($lei, @args);
+ # _post_augment_mbox
+ my $m = $self->can("_post_augment_$self->{base_type}") or return;
+ $m->($self, $lei, @args);
}
sub ipc_atfork_child {