Subject: | maildir support |
Maildir support was busted. This fixes:
--- Email-LocalDelivery/LocalDelivery/Maildir.pm 2003-02-22 02:09:44.000000000 +0000
+++ Email-LocalDelivery~/LocalDelivery/Maildir.pm 2003-04-04 10:55:47.000000000 +0100
@@ -1,3 +1,4 @@
+use strict;
package Email::LocalDelivery::Maildir;
use Email::Simple;
use File::Path;
@@ -9,13 +10,12 @@
sub deliver {
my ($class, $mail, @files) = @_;
- my @rv;
$mail = Email::Simple->new($mail)
unless ref $mail eq "Email::Simple"; # For when we recurse
$class->fix_lines($mail);
$class->update_time();
- $temp_file = $class->write_temp($mail, @files) || return ();
+ my $temp_file = $class->write_temp($mail, @files) || return ();
my @written = $class->write_links($mail, $temp_file, @files);
unlink $temp_file;
@@ -40,10 +40,9 @@
for my $file (@files) {
$file =~ s{/$}{};
my $tmp_file = $class->get_filename_in($file."/tmp");
- mkpath([map { "$file/$_" } qw(tmp new cur)]) or next;
+ eval { mkpath([map { "$file/$_" } qw(tmp new cur)]); 1 } or next;
$class->write_message($mail, $tmp_file)
and return $tmp_file;
- use File::Path;
}
return;
}
@@ -61,11 +60,11 @@
sub write_links {
my ($class, $mail, $temp_file, @files) = @_;
- my $rv;
+ my @rv;
for my $file (@files) {
$file =~ s{/$}{};
my $new_location = $class->get_filename_in($file."/new");
- mkpath([map { "$file/$_" } qw(tmp new cur)]) or next;
+ eval { mkpath([map { "$file/$_" } qw(tmp new cur)]); 1 } or next;
if (link $temp_file, $new_location) {
push @rv, $new_location;
} else {
@@ -80,7 +79,7 @@
sub write_message {
my ($class, $mail, $file) = @_;
- open my $fh, ">$file" || return;
- print $mail->as_string;
+ open my $fh, ">$file" or return;
+ print $fh $mail->as_string;
return close $fh;
}