[LON-CAPA-cvs] cvs: loncom /debugging_tools db_copy.pl

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 20 Sep 2006 19:23:24 -0000


albertel		Wed Sep 20 15:23:24 2006 EDT

  Modified files:              
    /loncom/debugging_tools	db_copy.pl 
  Log:
  - use full c solution
  
  
Index: loncom/debugging_tools/db_copy.pl
diff -u loncom/debugging_tools/db_copy.pl:1.1 loncom/debugging_tools/db_copy.pl:1.2
--- loncom/debugging_tools/db_copy.pl:1.1	Thu Aug 24 18:46:30 2006
+++ loncom/debugging_tools/db_copy.pl	Wed Sep 20 15:23:24 2006
@@ -11,7 +11,8 @@
 use Cwd;
 
 my $dump_db = './dump_db';
-my $dir = './test';
+my $create_db = './create_db';
+my $dir = './annarbor';
 
 my  %perlvar=%{&LONCAPA::Configuration::read_conf('loncapa.conf')};
 
@@ -47,23 +48,11 @@
     return if ($_!~m/\.db$/);
     my $file = $_;
     my $dbref =&lock_db($file);
-    print("attempting $dbref\n");
+    print("attempting $file\n");
     my %newdb;
     my $new_file = $file.'.new';
-    if (!tie(%newdb,'GDBM_File',$new_file,&GDBM_WRCREAT(),0640)) {
-	die("unable to create new db $new_file $! $@");
-    }
-    open(my $fh,"$dump_db -f $file|");
-    while (my $entry = <$fh>) {
-	chomp($entry);
-	if ($entry =~/^ERROR:/) {
-	    die($entry);
-	}
-	my ($key,$value) = split(' -> ',$entry,2);
-	$newdb{&unescape($key)} = &unescape($value);
-    }
-    print("finishing $dbref\n");
-    untie(%newdb);
+    system("$dump_db -f $file|$create_db -f $new_file");
+#    print("finishing $dbref\n");
     untie($dbref);
     system("/bin/mv $file $file.old");
     system("/bin/mv $file.new $file");