[prev] [thread] [next] [lurker] [Date index for 2003/03/15]
Update of /cvsroot/siesta/siesta/lib/Siesta/Plugin In directory sc8-pr-cvs1:/tmp/cvs-serv18727 Modified Files: Archive.pm Log Message: use mail::localdelivery, to save having to grok maildir writing Index: Archive.pm =================================================================== RCS file: /cvsroot/siesta/siesta/lib/Siesta/Plugin/Archive.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Archive.pm 15 Mar 2003 21:25:19 -0000 1.8 +++ Archive.pm 15 Mar 2003 23:45:48 -0000 1.9 @@ -2,45 +2,25 @@ package Siesta::Plugin::Archive; use strict; use Siesta::Plugin; +use Mail::LocalDelivery; use base 'Siesta::Plugin'; use vars qw( $DESCRIPTION ); $DESCRIPTION = "save messages to maildirs"; use Siesta::Config; -use File::Path; - -my $sequence = 0; sub process { my $self = shift; my $mail = shift; - my $path = $Siesta::Config::ARCHIVE . "/" . $mail->list->name; - eval { - mkpath( [ map { "$path/$_" } qw( cur new tmp ) ], 0, 0777 ); - }; - die "Archive: couldn't create maildir: $@\nRunning as $>" if $@; - my $now = time; - $sequence++; - my $file = "$now.$$.$sequence"; - my $tmpfile = "$path/tmp/$file"; - my $newfile = "$path/new/$file"; + my $clone = $mail->clone; - local *FILE; - eval { - open FILE, ">$tmpfile" - or die "couldn't open '$tmpfile' $!"; - $mail->print( \*FILE ); - close FILE - or die "error writing '$tmpfile' $!"; - }; - if ($@) { - unlink $tmpfile; - die $@; - } - rename $tmpfile, $newfile - or die "couldn't rename '$tmpfile' '$newfile'"; + # this'll be fine so long as Siesta::Message remains a child + # of Mail::Internet + bless $clone, 'Mail::Internet'; + my $ld = new Mail::LocalDelivery $clone; + $ld->deliver( "$Siesta::Config::ARCHIVE/" . $mail->list->name . "/" ); return; }
Generated at 13:57 on 01 Jul 2004 by mariachi 0.52