|
From: <jgr...@us...> - 2003-09-09 05:05:54
|
Update of /cvsroot/popfile/engine/UI
In directory sc8-pr-cvs1:/tmp/cvs-serv27342/UI
Modified Files:
HTML.pm
Log Message:
English.msg:
Fixed a message that had no trailing </font> and would produce
incorrect HTML.
HTML.pm:
Further work on the performance of the loading and organizing
of the history from disk. Start up is now much faster when
messages have previously been cached to disk. Removal of old
files is delayed until a TICKD event.
Removed various lines of dead/legacy code revealed by the
test suite.
Changed the various checkboxes that are used for history deletion
from all being called remove to having individual names, this
makes them easier to test.
Removed the code for invalidating the history cache, this is
no longer needed because the progressive history update does
away with the need to go looking on disk for changes except
for at startup.
Bayes.pm:
Make QuickMagnets work again.
Change cutoff for unsure messages to 0.4.
Add some close statements to the matrix loader which were missing.
TestModule.tst:
Initialize the logger to prevent a Perl warning.
TestConfiguration.tst:
Fix tests that break with ActivePerl because sort is returning
values in a different order.
TestProxy.pm:
Started working with ActivePerl for the test suite and
discovered that it considers 0 to be a valid port number so
use the port number -1 for bad port number tests.
TestHTTP.pm:
Started working with ActivePerl for the test suite and
discovered that it considers 0 to be a valid port number so
use the port number -1 for bad port number tests.
TestHTML.tst/TestHTML.script:
Tests for QuickMagnets, reclassification, message deletion,
reading of ICO, GIF, PNG, LOG, HTML and CSS files, tests for
the disk caching of history data, archiving of history files.
Additional safety code in the test runner to spot bad
scripts or return codes from HTTP requests. New code to
follow redirects on form submission.
TestHTML.tst now covers 97% of HTML.pm's code. Remaining
tests needed are for the display of magnetized mails.
TestMailParse009.wrd/TestMailParse023.wrd:
Update words list since we now correctly add the domain name
from within an img src tag.
Index: HTML.pm
===================================================================
RCS file: /cvsroot/popfile/engine/UI/HTML.pm,v
retrieving revision 1.198
retrieving revision 1.199
diff -C2 -d -r1.198 -r1.199
*** HTML.pm 5 Sep 2003 21:11:58 -0000 1.198
--- HTML.pm 8 Sep 2003 18:03:57 -0000 1.199
***************
*** 91,97 ****
# in the current filter, sort or search set.
#
- # history_invalid is set to cause the history cache to be reloaded by a call to
- # load_history_cache__, and is set by a call to invalidate_history_cache
- #
# If new items have been added to the history the set need_resort__ to 1 to ensure
# that the next time a history page is being displayed the appropriate sort, search
--- 91,94 ----
***************
*** 100,104 ****
$self->{history__} = {};
$self->{history_keys__} = ();
- $self->{history_invalid__} = 0;
$self->{need_resort__} = 0;
--- 97,100 ----
***************
*** 263,272 ****
# or History_NoSubject in while loading the cache
- $self->invalidate_history_cache();
$self->load_disk_cache__();
$self->load_history_cache__();
- $self->remove_mail_files();
-
return $self->SUPER::start();
}
--- 259,265 ----
***************
*** 284,288 ****
$self->copy_pre_cache__();
-
$self->save_disk_cache__();
}
--- 277,280 ----
***************
*** 413,418 ****
$self->parse_form_( $1 );
}
- } else {
- $url = '/';
}
} else {
--- 405,408 ----
***************
*** 466,470 ****
my $file = $self->{form_}{view};
! $self->copy_pre_cache__() if ($self->{need_resort__});
foreach my $akey ( keys %{ $self->{history__} } ) {
--- 456,460 ----
my $file = $self->{form_}{view};
! $self->copy_pre_cache__();
foreach my $akey ( keys %{ $self->{history__} } ) {
***************
*** 481,490 ****
$self->{form_}{setsearch} = 1;
! # Force a history_reload if we did not find this file in the history cache
! # but we do find it on disk using perl's -e file test operator (returns
! # true if the file exists).
!
! $self->invalidate_history_cache() if ( !$found );
! if ( -e ( $self->global_config_( 'msgdir' ) . $file ) ) {
$self->http_redirect_( $client, "/view?session=$self->{session_key__}&view=$self->{form_}{view}" );
} else {
--- 471,475 ----
$self->{form_}{setsearch} = 1;
! if ( $found ) {
$self->http_redirect_( $client, "/view?session=$self->{session_key__}&view=$self->{form_}{view}" );
} else {
***************
*** 2268,2273 ****
$body .= sprintf( $self->{language__}{Bucket_DoesNotAppear}, $word );
}
- } else {
- $body .= "<div class=\"error01\">$self->{language__}{Bucket_Error4}</div>";
}
--- 2253,2256 ----
***************
*** 2309,2327 ****
# ---------------------------------------------------------------------------------------------
#
- # invalidate_history_cache
- #
- # Called to notify the module that new files have been added to the history cache on disk
- # and the cache needs to be reloaded.
- #
- # ---------------------------------------------------------------------------------------------
- sub invalidate_history_cache
- {
- my ( $self ) = @_;
-
- $self->{history_invalid__} = 1;
- }
-
- # ---------------------------------------------------------------------------------------------
- #
# sort_filter_history
#
--- 2292,2295 ----
***************
*** 2583,2587 ****
}
- $self->{history_invalid__} = 0;
$self->{need_resort__} = 0;
$self->sort_filter_history( '', '', '' );
--- 2551,2554 ----
***************
*** 2686,2690 ****
}
! $self->{history__}{$file}{index} = $index;
}
--- 2653,2657 ----
}
! $self->{$cache}{$file}{index} = $index;
}
***************
*** 3102,3111 ****
# we are in control of deleting messages
! if ( defined($self->{form_}{remove_array}) ) {
! for my $i ( 0 .. $#{$self->{form_}{remove_array}} ) {
! $self->history_delete_file( $self->{history_keys__}[$self->{form_}{remove_array}[$i] - 1], 0);
! }
! } elsif ( defined($self->{form_}{remove}) ) {
! $self->history_delete_file( $self->{history_keys__}[$self->{form_}{remove} - 1], 0);
}
}
--- 3069,3076 ----
# we are in control of deleting messages
! for my $i ( keys %{$self->{form_}} ) {
! if ( $i =~ /^remove_(\d+)$/ ) {
! $self->history_delete_file( $self->{history_keys__}[$1 - 1], 0);
! }
}
}
***************
*** 3136,3140 ****
# applied. The watch word here is to avoid doing work
- $self->load_history_cache__() if ( $self->{history_invalid__} == 1 );
$self->sort_filter_history( $self->{form_}{filter}, # PROFILE BLOCK START
$self->{form_}{search},
--- 3101,3104 ----
***************
*** 3159,3163 ****
if ( !$self->history_cache_empty() ) {
- my $highlight_message = '';
my $start_message = 0;
--- 3123,3126 ----
***************
*** 3248,3258 ****
$body .= "<tr";
! if ( ( ( defined($self->{form_}{file}) && ( $self->{form_}{file} eq $mail_file ) ) ) || # PROFILE BLOCK START
! ( $highlight_message eq $mail_file ) ) { # PROFILE BLOCK STOP
! $body .= " class=\"rowHighlighted\"";
! } else {
! $body .= " class=\"";
! $body .= $stripe?"rowEven\"":"rowOdd\"";
! }
$stripe = 1 - $stripe;
--- 3211,3216 ----
$body .= "<tr";
! $body .= " class=\"";
! $body .= $stripe?"rowEven\"":"rowOdd\"";
$stripe = 1 - $stripe;
***************
*** 3270,3278 ****
$body .= " <input type=\"submit\" class=\"undoButton\" name=\"undo_$i\" value=\"$self->{language__}{Undo}\">\n";
} else {
! if ( !defined($self->{classifier__}->get_bucket_color($bucket))) {
! $body .= "$bucket</td>\n<td>";
! } else {
! $body .= "<a href=\"buckets?session=$self->{session_key__}&showbucket=$bucket\"><font color=\"" . $self->{classifier__}->get_bucket_color($bucket) . "\">$bucket</font></a></td>\n<td>";
! }
if ( $self->{history__}{$mail_file}{magnet} eq '' ) {
--- 3228,3232 ----
$body .= " <input type=\"submit\" class=\"undoButton\" name=\"undo_$i\" value=\"$self->{language__}{Undo}\">\n";
} else {
! $body .= "<a href=\"buckets?session=$self->{session_key__}&showbucket=$bucket\"><font color=\"" . $self->{classifier__}->get_bucket_color($bucket) . "\">$bucket</font></a></td>\n<td>";
if ( $self->{history__}{$mail_file}{magnet} eq '' ) {
***************
*** 3294,3298 ****
$body .= "</td>\n<td>\n";
$body .= "<label class=\"removeLabel\" for=\"remove_" . ( $i+1 ) . "\">$self->{language__}{Remove}</label>\n";
! $body .= "<input type=\"checkbox\" id=\"remove_" . ( $i+1 ) . "\" class=\"checkbox\" name=\"remove\" value=\"" . ( $i+1 ) . "\" />\n";
$body .= "</td>\n</tr>\n";
--- 3248,3252 ----
$body .= "</td>\n<td>\n";
$body .= "<label class=\"removeLabel\" for=\"remove_" . ( $i+1 ) . "\">$self->{language__}{Remove}</label>\n";
! $body .= "<input type=\"checkbox\" id=\"remove_" . ( $i+1 ) . "\" class=\"checkbox\" name=\"remove_" . ($i+1) . "\"/>\n";
$body .= "</td>\n</tr>\n";
***************
*** 3346,3359 ****
my ( $self, $client ) = @_;
- $self->load_history_cache__() if ( $self->{history_invalid__} == 1 );
-
- if ( $self->{need_resort__} == 1 ) {
-
- $self->copy_pre_cache__();
- $self->sort_filter_history( (defined($self->{form_}{filter})?$self->{form_}{filter}:''),
- (defined($self->{form_}{search})?$self->{form_}{search}:''),
- (defined($self->{form_}{sort})?$self->{form_}{sort}:'') );
- }
-
my $mail_file = $self->{form_}{view};
my $start_message = $self->{form_}{start_message} || 0;
--- 3300,3303 ----
***************
*** 3368,3400 ****
my $index = -1;
! foreach my $i ( $start_message .. $start_message + $page_size - 1) {
if ( $self->{history_keys__}[$i] eq $mail_file ) {
! $index = $i;
last;
}
}
- # If we fail to find the index of the message we are looking for then
- # do a full search of the history for it
-
- if ( $index == -1 ) {
- foreach my $i ( 0 .. $self->history_size()-1 ) {
- if ( $self->{history_keys__}[$i] eq $mail_file ) {
- use integer;
- $index = $i;
- $start_message = ($i / $page_size ) * $page_size;
- $self->{form_}{start_message} = $start_message;
- last;
- }
- }
- }
-
- # If we still can't find the message then return to the history page
-
- if ( $index == -1 ) {
- $self->log_("view page cache miss");
- return $self->http_redirect_( $client, '/history' );
- }
-
my $body = "<table width=\"100%\" summary=\"\">\n<tr>\n<td align=\"left\">\n";
--- 3312,3326 ----
my $index = -1;
!
! foreach my $i ( 0 .. $self->history_size()-1 ) {
if ( $self->{history_keys__}[$i] eq $mail_file ) {
! use integer;
! $index = $i;
! $start_message = ($i / $page_size ) * $page_size;
! $self->{form_}{start_message} = $start_message;
last;
}
}
my $body = "<table width=\"100%\" summary=\"\">\n<tr>\n<td align=\"left\">\n";
***************
*** 3696,3699 ****
--- 3622,3626 ----
# ---------------------------------------------------------------------------------------------
+ #
# copy_pre_cache__
#
***************
*** 3706,3714 ****
# Copy the history pre-cache over AFTER any possibly index-based remove operations are complete
! foreach my $file ( keys( %{$self->{history_pre_cache__}} ) ) {
! $self->{history__}{$file} = \%{$self->{history_pre_cache__}{$file}};
delete $self->{history_pre_cache__}{$file};
}
$self->{history_pre_cache__} = {};
}
--- 3633,3649 ----
# Copy the history pre-cache over AFTER any possibly index-based remove operations are complete
!
! my $index = $self->history_size() + 1;
! my $added = 0;
! foreach my $file (sort compare_mf keys %{$self->{history_pre_cache__}} ) {
! $self->{history__}{$file} = $self->{history_pre_cache__}{$file};
! $self->{history__}{$file}{index} = $index;
! $index += 1;
! $added = 1;
delete $self->{history_pre_cache__}{$file};
}
+
$self->{history_pre_cache__} = {};
+ $self->sort_filter_history( '', '', '' ) if ( $added );
}
***************
*** 3728,3732 ****
while ( my $mail_file = readdir MESSAGES ) {
! if ( $mail_file =~ /popfile\d+=\d+\.msg$/ ) {
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat( $self->global_config_( 'msgdir' ) . $mail_file);
--- 3663,3667 ----
while ( my $mail_file = readdir MESSAGES ) {
! if ( $mail_file =~ /popfile(\d+)=\d+\.msg$/ ) {
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat( $self->global_config_( 'msgdir' ) . $mail_file);
***************
*** 3784,3788 ****
my ($reclassified, $bucket, $usedtobe, $magnet) = $self->{classifier__}->history_read_class( $mail_file );
! if ( ( $bucket ne 'unclassified' ) && ( $bucket ne 'unknown class' ) ) {
$path .= "\/" . $bucket;
mkdir( $path );
--- 3719,3723 ----
my ($reclassified, $bucket, $usedtobe, $magnet) = $self->{classifier__}->history_read_class( $mail_file );
! if ( ( $bucket ne 'unclassified' ) && ( $bucket ne 'unknown class' ) && ( $bucket ne 'unsure' ) ) {
$path .= "\/" . $bucket;
mkdir( $path );
***************
*** 3884,3889 ****
}
! return $formstring if ($count > 0);
! return '';
}
--- 3819,3823 ----
}
! return ($count>0)?$formstring:'';
}
|