diff options
| author | fukachan <fukachan> | 2004-05-28 03:53:50 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2004-05-28 03:53:50 +0000 |
| commit | 8d6c8199a5eb1642950e8e0574af7aaae4842ee4 (patch) | |
| tree | 5b0b3ada19b7f59c05b29fb4343809a993df0efd /fml | |
| parent | d7dbef6d63b3959bed8d4c8a68ed2ec78a92172c (diff) | |
| download | fml8-8d6c8199a5eb1642950e8e0574af7aaae4842ee4.tar.gz fml8-8d6c8199a5eb1642950e8e0574af7aaae4842ee4.tar.bz2 fml8-8d6c8199a5eb1642950e8e0574af7aaae4842ee4.zip | |
When we fail to create article file, we try to save the original
message at least.
Diffstat (limited to 'fml')
| -rw-r--r-- | fml/lib/FML/Article.pm | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/fml/lib/FML/Article.pm b/fml/lib/FML/Article.pm index 08ac2541..eec23a9b 100644 --- a/fml/lib/FML/Article.pm +++ b/fml/lib/FML/Article.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Article.pm,v 1.64 2004/05/18 08:36:05 fukachan Exp $ +# $FML: Article.pm,v 1.65 2004/05/25 04:04:43 fukachan Exp $ # package FML::Article; @@ -185,12 +185,13 @@ sub spool_in $error++ if $fh->error(); if ($error) { - $fh->close; - $curproc->logerror("failed to create article"); + $fh->close; + $curproc->logerror("failed to create article"); + $self->_try_failover($curproc, $file); } else { - $fh->close; - $curproc->log("article $id"); + $fh->close; + $curproc->log("article $id"); } } } @@ -206,6 +207,36 @@ sub spool_in } +# Descriptions: When we fail to create article file, +# we try to save the original message at least. +# So, we try to save article content from incoming queue. +# Arguments: OBJ($self) OBJ($curproc) STR($article_file) +# Side Effects: link(2) or rename(2). +# Return Value: none +sub _try_failover +{ + my ($self, $curproc, $article_file) = @_; + my $queue = $curproc->mail_queue_get_incoming_queue(); + my $queue_id = $queue->id(); + my $queue_file = $queue->incoming_file_path($queue_id); + + # 0. nuke (must be) broken article file. + if (-f $article_file) { unlink $article_file;} + + # 1. try link(2). + if (link($queue_file, $article_file)) { + $curproc->log("article: link queue to article file"); + } + # 2. try rename(2). + elsif (rename($queue_file, $article_file)) { + $curproc->log("article: rename queue to article file"); + } + else { + $curproc->logerror("article: give up failover."); + } +} + + =head2 filepath($id) return article file path. |
