|
From: <jgr...@us...> - 2003-09-05 21:12:05
|
Update of /cvsroot/popfile/engine/UI
In directory sc8-pr-cvs1:/tmp/cvs-serv3906/UI
Modified Files:
HTML.pm
Log Message:
Speed optimization of history reload after successful shutdown and message deletion. Both use readdir instead of glob
Index: HTML.pm
===================================================================
RCS file: /cvsroot/popfile/engine/UI/HTML.pm,v
retrieving revision 1.197
retrieving revision 1.198
diff -C2 -d -r1.197 -r1.198
*** HTML.pm 24 Aug 2003 01:20:33 -0000 1.197
--- HTML.pm 5 Sep 2003 21:11:58 -0000 1.198
***************
*** 266,270 ****
$self->load_disk_cache__();
$self->load_history_cache__();
- $self->sort_filter_history( '', '', '' );
$self->remove_mail_files();
--- 266,269 ----
***************
*** 2544,2570 ****
# for non-culling and new entries that need to be added to the end
! my @history_files = sort compare_mf glob( $self->global_config_( 'msgdir' ) . "popfile*=*.msg" );
! foreach my $i ( 0 .. $#history_files ) {
! # Strip any directory portion of the name in the current file so that we
! # just get the base name of the file that we are dealing with
! $history_files[$i] =~ /(popfile(\d+)=\d+\.msg)$/;
! $history_files[$i] = $1;
! if ( $2 > $max ) {
! $max = $2;
}
! # If this file already exists in the history cache then just mark it not
! # to be culled and move on.
! if ( defined( $self->{history__}{$history_files[$i]} ) ) {
! $self->{history__}{$history_files[$i]}{cull} = 0;
! $self->{history__}{$history_files[$i]}{index} = $i;
! } else {
! $self->new_history_file__( $history_files[$i], $i );
! }
}
--- 2543,2570 ----
# for non-culling and new entries that need to be added to the end
! opendir MESSAGES, $self->global_config_( 'msgdir' );
! my @history_files;
! while ( my $entry = readdir MESSAGES ) {
! if ( $entry =~ /(popfile(\d+)=\d+\.msg)$/ ) {
! $entry = $1;
! if ( $2 > $max ) {
! $max = $2;
! }
! if ( defined( $self->{history__}{$entry} ) ) {
! $self->{history__}{$entry}{cull} = 0;
! } else {
! push @history_files, ($entry);
! }
}
+ }
! closedir MESSAGES;
! foreach my $i ( 0 .. $#history_files ) {
! $self->new_history_file__( $history_files[$i] );
}
***************
*** 2572,2578 ****
# comment at the start of this function for more detail
! foreach my $key (keys %{$self->{history__}}) {
if ( $self->{history__}{$key}{cull} == 1 ) {
delete $self->{history__}{$key};
}
}
--- 2572,2583 ----
# comment at the start of this function for more detail
! my $index = 0;
!
! foreach my $key (sort compare_mf keys %{$self->{history__}}) {
if ( $self->{history__}{$key}{cull} == 1 ) {
delete $self->{history__}{$key};
+ } else {
+ $self->{history__}{$key}{index} = $index;
+ $index += 1;
}
}
***************
*** 3720,3736 ****
my ( $self ) = @_;
! my @mail_files = glob( $self->global_config_( 'msgdir' ) . "popfile*=*.msg" );
! foreach my $mail_file (@mail_files) {
! my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($mail_file);
! if ( $ctime < (time - $self->config_( 'history_days' ) * $seconds_per_day) ) {
! $self->history_delete_file( $mail_file, $self->config_( 'archive' ) );
}
}
# Clean up old style msg/cls files
! @mail_files = glob( $self->global_config_( 'msgdir' ) . "popfile*_*.???" );
foreach my $mail_file (@mail_files) {
--- 3725,3745 ----
my ( $self ) = @_;
! opendir MESSAGES, $self->global_config_( 'msgdir' );
! 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);
! if ( $ctime < (time - $self->config_( 'history_days' ) * $seconds_per_day) ) {
! $self->history_delete_file( $mail_file, $self->config_( 'archive' ) );
! }
}
}
+ closedir MESSAGES;
+
# Clean up old style msg/cls files
! my @mail_files = glob( $self->global_config_( 'msgdir' ) . "popfile*_*.???" );
foreach my $mail_file (@mail_files) {
|