--- loncom/debugging_tools/rebuild_db_from_hist.pl 2004/12/08 22:06:48 1.1 +++ loncom/debugging_tools/rebuild_db_from_hist.pl 2004/12/09 20:01:48 1.3 @@ -4,7 +4,7 @@ # # rebuild_db_from_hist.pl Rebuild a *.db file from a *.hist file # -# $Id: rebuild_db_from_hist.pl,v 1.1 2004/12/08 22:06:48 matthew Exp $ +# $Id: rebuild_db_from_hist.pl,v 1.3 2004/12/09 20:01:48 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -50,11 +50,12 @@ if ($help) { rebuild_db_from_hist.pl - recreate a db file from a hist file. Options: -help Display this help. - -debug Output debugging code - -sort Sort the entries by time - -test Do not write the data but verify it was created properly + -debug Output debugging code (not much is output yet) + -test Verify the given *.hist file will reconstruct the current db file + Sends error messages to STDERR. Examples: - rebuild_db_from_hist.pl $file.hist + rebuild_db_from_hist.pl -t $file.hist # Perform a test rebuild + rebuild_db_from_hist.pl $file.hist END exit; } @@ -68,7 +69,7 @@ while (my $fname = shift) { print STDERR "Aborting: The target file $db_filename exists.".$/; next; } - my ($error,$constructed_hash) = &process_file($fname,$db_filename); + my ($error,$constructed_hash) = &process_file($fname,$db_filename,$debug); if (! defined($error) || ! $test) { $error = &write_hash($db_filename,$constructed_hash); } @@ -103,6 +104,9 @@ sub process_file { # P:put # D:delete my ($action,$time,$concatenated_data) = split(':',$command,3); + if ($fname eq 'roles.hist' && $concatenated_data =~ /^.*:.*:/) { + (undef,undef,$concatenated_data) = split(':',$concatenated_data,3); + } my @data = split('&',$concatenated_data); foreach my $k_v_pair (@data) { my ($key,$value) = split('=',$k_v_pair,2);