[LON-CAPA-cvs] cvs: loncom /metadata_database searchcat.pl

matthew lon-capa-cvs@mail.lon-capa.org
Fri, 08 Aug 2003 12:38:00 -0000


matthew		Fri Aug  8 08:38:00 2003 EDT

  Modified files:              
    /loncom/metadata_database	searchcat.pl 
  Log:
  Added check on the ratio of the sizes of the nohist_reseval.db and
  nohist_new_reseval.db files.  This will hopefully prevent us from 
  overwriting data.
  
  
Index: loncom/metadata_database/searchcat.pl
diff -u loncom/metadata_database/searchcat.pl:1.36 loncom/metadata_database/searchcat.pl:1.37
--- loncom/metadata_database/searchcat.pl:1.36	Wed Jul 30 12:49:27 2003
+++ loncom/metadata_database/searchcat.pl	Fri Aug  8 08:38:00 2003
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # searchcat.pl "Search Catalog" batch script
 #
-# $Id: searchcat.pl,v 1.36 2003/07/30 16:49:27 www Exp $
+# $Id: searchcat.pl,v 1.37 2003/08/08 12:38:00 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -316,8 +316,27 @@
     # ... not yet implemented
         
     # ------------------------------------------- Copy over the new db-files
-    system('mv '.$prodir.'/nohist_new_resevaldata.db '.
-           $prodir.'/nohist_resevaldata.db');
+    #
+    # Check the size of nohist_new_resevaldata.db compared to 
+    # nohist_resevaldata.db
+    my @stat_result = stat($prodir.'/nohist_new_resevaldata.db');
+    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");
+    }
+        
 }
 # --------------------------------------------------- Close database connection
 $dbh->disconnect;