[LON-CAPA-cvs] cvs: loncom /metadata_database searchcat.pl
www
lon-capa-cvs@mail.lon-capa.org
Thu, 21 Aug 2003 00:19:05 -0000
www Wed Aug 20 20:19:05 2003 EDT
Modified files:
/loncom/metadata_database searchcat.pl
Log:
Crashed with
Illegal division by zero at searchcat.pl line 347.
when hitting the first author who had no resevaldata yet ($oldsize=0).
Discovered while adding MIME-type count.
Index: loncom/metadata_database/searchcat.pl
diff -u loncom/metadata_database/searchcat.pl:1.37 loncom/metadata_database/searchcat.pl:1.38
--- loncom/metadata_database/searchcat.pl:1.37 Fri Aug 8 08:38:00 2003
+++ loncom/metadata_database/searchcat.pl Wed Aug 20 20:19:05 2003
@@ -2,7 +2,7 @@
# The LearningOnline Network
# searchcat.pl "Search Catalog" batch script
#
-# $Id: searchcat.pl,v 1.37 2003/08/08 12:38:00 matthew Exp $
+# $Id: searchcat.pl,v 1.38 2003/08/21 00:19:05 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -77,6 +77,7 @@
my @metalist;
$simplestatus='';
+my %countext=();
sub writesimple {
open(SMP,'>/home/httpd/html/lon-status/mysql.txt');
@@ -84,6 +85,25 @@
close(SMP);
}
+sub writecount {
+ open(RSMP,'>/home/httpd/html/lon-status/rescount.txt');
+ foreach (keys %countext) {
+ print RSMP $_.'='.$countext{$_}.'&';
+ }
+ print RSMP 'time='.time."\n";
+ close(RSMP);
+}
+
+sub count {
+ my $file=shift;
+ $file=~/\.(\w+)$/;
+ my $ext=lc($1);
+ if (defined($countext{$ext})) {
+ $countext{$ext}++;
+ } else {
+ $countext{$ext}=1;
+ }
+}
# ----------------------------------------------------- Un-Escape Special Chars
sub unescape {
@@ -290,6 +310,7 @@
my $m2='/res/'.&declutter($m);
$m2=~s/\.meta$//;
&dynamicmeta($m2);
+ &count($m2);
$delete_sth->execute($m2);
$insert_sth->execute($ref->{'title'},
$ref->{'author'},
@@ -323,26 +344,28 @@
my $new_size = $stat_result[7];
@stat_result = stat($prodir.'/nohist_resevaldata.db');
my $old_size = $stat_result[7];
- if ($new_size/$old_size > 0.15 ) {
- system('mv '.$prodir.'/nohist_new_resevaldata.db '.
- $prodir.'/nohist_resevaldata.db');
- } else {
- print LOG "Size of '$user' old nohist_reseval: $old_size ".
- "Size of new: $new_size. Not overwriting.\n";
- my $emailto="$perlvar{'lonAdmEMail'},$perlvar{'lonSysEMail'}";
- my $subj="LON: $perlvar{'lonHostID'} searchcat.pl $user reseval ".
- "modification error.";
- system("echo ".
- "'See /home/httpd/perl/logs/searchcat.txt for information.' ".
- "| mailto $emailto -s '$subj' > /dev/null");
- }
-
+ if ($old_size) {
+ if ($new_size/$old_size > 0.15 ) {
+ system('mv '.$prodir.'/nohist_new_resevaldata.db '.
+ $prodir.'/nohist_resevaldata.db');
+ } else {
+ print LOG "Size of '$user' old nohist_reseval: $old_size ".
+ "Size of new: $new_size. Not overwriting.\n";
+ my $emailto="$perlvar{'lonAdmEMail'},$perlvar{'lonSysEMail'}";
+ my $subj="LON: $perlvar{'lonHostID'} searchcat.pl $user reseval ".
+ "modification error.";
+ system("echo ".
+ "'See /home/httpd/perl/logs/searchcat.txt for information.' ".
+ "| mailto $emailto -s '$subj' > /dev/null");
+ }
+ }
}
# --------------------------------------------------- Close database connection
$dbh->disconnect;
print LOG "\n==== Searchcat completed ".localtime()." ====\n";
close(LOG);
&writesimple();
+&writecount();
exit 0;