|
From: <ssc...@us...> - 2003-06-24 03:31:05
|
Update of /cvsroot/popfile/engine/Proxy
In directory sc8-pr-cvs1:/tmp/cvs-serv25859
Modified Files:
POP3.pm
Log Message:
make message downloading more efficient
by indexing files based on POP3 parameter
moved .cls file handling to Bayes.pm
Index: POP3.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Proxy/POP3.pm,v
retrieving revision 1.56
retrieving revision 1.57
diff -C2 -d -r1.56 -r1.57
*** POP3.pm 14 Jun 2003 21:10:12 -0000 1.56
--- POP3.pm 24 Jun 2003 03:31:02 -0000 1.57
***************
*** 113,119 ****
{
my ( $self, $client, $download_count, $pipe ) = @_;
# Number of messages downloaded in this session
! my $count = 0;
# The handle to the real mail server gets stored here
--- 113,122 ----
{
my ( $self, $client, $download_count, $pipe ) = @_;
+
+ # Hash of indexes of downloaded messages
+ my %downloaded;
# Number of messages downloaded in this session
! #my $count = 0;
# The handle to the real mail server gets stored here
***************
*** 269,278 ****
if ( $2 ne '99999999' ) {
if ( $self->config_( 'toptoo' ) ) {
if ( $self->echo_response_($mail, $client, "RETR $1" ) ) {
! # Classify without echoing to client, without saving
! # and without over-writing any files ($mcount overriden to 0)
! my $class = $self->{classifier__}->classify_and_modify( $mail, undef, $download_count, 0, 1, '', 0 );
if ( $self->echo_response_($mail, $client, $command ) ) {
--- 272,285 ----
if ( $2 ne '99999999' ) {
if ( $self->config_( 'toptoo' ) ) {
+
+ my $count = $1;
+
if ( $self->echo_response_($mail, $client, "RETR $1" ) ) {
! # Classify without echoing to client, saving file for later RETR's
! my $class = $self->{classifier__}->classify_and_modify( $mail, $client, $download_count, $count, 0, '', 0 );
!
! $downloaded{$count} = 1;
if ( $self->echo_response_($mail, $client, $command ) ) {
***************
*** 337,351 ****
# is done so that fetchmail can be used with POPFile.
if ( ( $command =~ /RETR (.*)/i ) || ( $command =~ /TOP (.*) 99999999/i ) ) {
! # Get the message from the remote server, if there's an error then we're done, but if not then
! # we echo each line of the message until we hit the . at the end
! if ( $self->echo_response_($mail, $client, $command ) ) {
! $count += 1;
! my $class = $self->{classifier__}->classify_and_modify( $mail, $client, $download_count, $count, 0, '' );
! # Tell the parent that we just handled a mail
! print $pipe "CLASS:$class$eol";
! $self->flush_extra_( $mail, $client, 0 );
next;
}
}
--- 344,407 ----
# is done so that fetchmail can be used with POPFile.
if ( ( $command =~ /RETR (.*)/i ) || ( $command =~ /TOP (.*) 99999999/i ) ) {
!
! my $count = $1;
! my $class;
!
! my $file = $self->{classifier__}->history_filename($download_count, $count);
! my $short_file = $file;
! $short_file =~ s/^[^\/]*\///;
!
! if (defined($downloaded{$count}) && open( RETRFILE, "<$file" ) ) {
! # File has been fetched and classified already
!
! $self->log_( "Printing message from cache" );
!
! if (0) {
! # Ensure a .CRLF is on the end of the file (may be neccessary)
! open APPEND, ">>$file";
! binmode APPEND;
! print APPEND ".$eol";
! close APPEND;
! }
! # Give the client an +OK:
! print $client "+OK file data cached by POPFile$eol";
! # Load the last classification
!
! my ( $reclassified, $bucket, $usedtobe, $magnet) = $self->{classifier__}->history_load_class($short_file);
!
! if ($bucket ne 'unknown class') {
! # echo file, inserting known classification, without saving
!
! $class = $self->{classifier__}->classify_and_modify( \*RETRFILE, $client, $download_count, 0, 1, $bucket );
! } else {
! # If the class wasn't saved properly, classify from disk normally
!
! $class = $self->{classifier__}->classify_and_modify( \*RETRFILE, $client, $download_count, 0, 1, '' );
!
! print $pipe "CLASS:$class$eol";
!
! }
! close RETRFILE;
! print $client ".$eol";
next;
+ } else {
+ # Retrieve file directly from the server
+
+ # Get the message from the remote server, if there's an error then we're done, but if not then
+ # we echo each line of the message until we hit the . at the end
+ if ( $self->echo_response_($mail, $client, $command ) ) {
+ $class = $self->{classifier__}->classify_and_modify( $mail, $client, $download_count, $count, 0, '' );
+
+ # Tell the parent that we just handled a mail
+ print $pipe "CLASS:$class$eol";
+
+ # Note locally that file has been retrieved
+ $downloaded{$count} = 1;
+
+ $self->flush_extra_( $mail, $client, 0 );
+ next;
+ }
}
}
|