summaryrefslogtreecommitdiff
path: root/fml
diff options
context:
space:
mode:
authorfukachan <fukachan>2004-12-15 13:16:42 +0000
committerfukachan <fukachan>2004-12-15 13:16:42 +0000
commit68bb0bf319181b31d95bbeaf132839716ddd2cec (patch)
tree86ccad72bde4e2a2fe19d52415606c6b7581ad4e /fml
parentc42cd3e36f542357cb52705f66e2f06fdc627a8a (diff)
downloadfml8-68bb0bf319181b31d95bbeaf132839716ddd2cec.tar.gz
fml8-68bb0bf319181b31d95bbeaf132839716ddd2cec.tar.bz2
fml8-68bb0bf319181b31d95bbeaf132839716ddd2cec.zip
implement clean_up() method
Diffstat (limited to 'fml')
-rw-r--r--fml/lib/Mail/Delivery/Queue.pm45
1 files changed, 44 insertions, 1 deletions
diff --git a/fml/lib/Mail/Delivery/Queue.pm b/fml/lib/Mail/Delivery/Queue.pm
index df864a7a..46e55876 100644
--- a/fml/lib/Mail/Delivery/Queue.pm
+++ b/fml/lib/Mail/Delivery/Queue.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: Queue.pm,v 1.48 2004/09/23 08:05:51 fukachan Exp $
+# $FML: Queue.pm,v 1.49 2004/12/15 06:46:19 fukachan Exp $
#
package Mail::Delivery::Queue;
@@ -1369,6 +1369,49 @@ sub set_log_function
}
+=head1 CLEAN UP GARBAGES
+
+=head2 clean_up()
+
+remove too old incoming queue files.
+
+=cut
+
+
+# Descriptions: remove too old incoming queue files.
+# Arguments: OBJ($self)
+# Side Effects: remove too old incoming queue files.
+# Return Value: none
+sub clean_up
+{
+ my ($self) = @_;
+ my $dir = $self->{ _directory } || croak("directory undefined");
+ my $limit = 14*24*3600;
+
+ use DirHandle;
+ use File::stat;
+ my $incoming_queue_dir = File::Spec->catfile($dir, "incoming");
+ my $dh = new DirHandle $incoming_queue_dir;
+ if (defined $dh) {
+ my ($file, $entry, $stat);
+ my $day_limit = time - $limit;
+
+ ENTRY:
+ while ($entry = $dh->read()) {
+ next ENTRY if $entry =~ /^\./o;
+
+ $file = File::Spec->catfile($dir, "incoming", $entry);
+ $stat = stat($file);
+ if ($stat->mtime < $day_limit) {
+ $self->log("remove too old incoming queue: qid=$entry");
+ unlink $file;
+ }
+ }
+ $dh->close();
+ }
+}
+
+
=head1 DEBUG
=cut