You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2006/10/16 20:07:57 UTC

svn commit: r464598 - /spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm

Author: jm
Date: Mon Oct 16 11:07:56 2006
New Revision: 464598

URL: http://svn.apache.org/viewvc?view=rev&rev=464598
Log:
optimisation; no need for mass-check to even open mail files that have a modtime older than the --after date

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm?view=diff&rev=464598&r1=464597&r2=464598
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/ArchiveIterator.pm Mon Oct 16 11:07:56 2006
@@ -569,7 +569,7 @@
 
 ############################################################################
 
-sub message_is_useful_by_date  {
+sub message_is_useful_by_date {
   my ($self, $date) = @_;
 
   return 0 unless $date;	# undef or 0 date = unusable
@@ -579,7 +579,7 @@
     return 1;
   }
   elsif (!$self->{opt_before}) {
-    # Just case about after
+    # Just care about after
     return $date > $self->{opt_after};
   }
   else {
@@ -587,6 +587,24 @@
   }
 }
 
+# additional check, based solely on a file's mod timestamp.  we cannot
+# make assumptions about --before, since the file may have been "touch"ed
+# since the last message was appended; but we can assume that too-old
+# files cannot contain messages newer than their modtime.
+sub message_is_useful_by_file_modtime {
+  my ($self, $date) = @_;
+
+  # better safe than sorry, if date is undef; let other stuff catch errors
+  return 1 unless $date;
+
+  if ($self->{opt_after}) {
+    return ($date > $self->{opt_after});
+  }
+  else {
+    return 1;       # --after not in use
+  }
+}
+
 ############################################################################
 
 # 0 850852128			atime
@@ -646,13 +664,16 @@
   my ($self, $class, $mail) = @_;
 
   $self->bump_scan_progress();
+
+  my @s = stat($file);
+  return unless $self->message_is_useful_by_file_modtime($s[9]);
+
   if (!$self->{determine_receive_date}) {
     push(@{$self->{$class}}, index_pack(AI_TIME_UNKNOWN, $class, "f", $mail));
     return;
   }
 
   my $date;
-
   unless (defined $AICache and $date = $AICache->check($mail)) {
     my $header;
     if (!mail_open($mail)) {
@@ -706,6 +727,9 @@
       next;
     }
 
+    my @s = stat($file);
+    next unless $self->message_is_useful_by_file_modtime($s[9]);
+
     my $info = {};
     my $count;
 
@@ -807,6 +831,9 @@
       $self->{access_problem} = 1;
       next;
     }
+
+    my @s = stat($file);
+    next unless $self->message_is_useful_by_file_modtime($s[9]);
 
     my $info = {};
     my $count;