]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiToMail.pm
lei_to_mail: get rid of empty _post_augment_maildir
[public-inbox.git] / lib / PublicInbox / LeiToMail.pm
index f0adc44f23e6088b13e40d43b01fec9fa1705c7d..e89cca712e17ab7098d9404f17d313d6b4ef8dff 100644 (file)
@@ -302,8 +302,9 @@ sub _buf2maildir {
                $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";
@@ -357,7 +358,7 @@ sub new {
                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";
@@ -393,8 +394,6 @@ sub _do_augment_maildir {
        }
 }
 
-sub _post_augment_maildir {} # noop
-
 sub _pre_augment_mbox {
        my ($self, $lei) = @_;
        my $dst = $lei->{ovv}->{dst};
@@ -440,8 +439,8 @@ sub _do_augment_mbox {
 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
@@ -454,9 +453,9 @@ 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 {