--- trunk/script/wait_admin 2004/05/27 22:05:53 100 +++ trunk/script/wait_admin 2004/05/30 12:49:46 101 @@ -56,6 +56,8 @@ =item * out of sync catalog and meta file data +=item * corrupted table data in catalog/meta (remove only!) + =back This will be done performing following steps: @@ -185,7 +187,9 @@ =item * compare content of meta and catalog files Data might differ, depending on ordering of variables in Storable and -Data::Dumper structures and ability to store structure correctly (it seems that there is always difference in one variable). +Data::Dumper structures and ability to store structure correctly (it seems that there is always difference in 'attr' variable). If you select +B<-verbose> flag, you will also see diff between catalog and meta file, so +you can decide do you want to re-sync them or not. If differences are found, you will be offered to select master copy (catalog or meta). You can also accept default none which will skip synchronization @@ -291,11 +295,26 @@ =cut +sub remove_table { + my $t = shift; + + if (do_fix("Do you want to remove table '$t' from database?")) { + delete $catalog->{'tables'}->{$t} || warn "can't delete table $t from catalog!"; + $cc++; + log_info("table '$t' removed from database $OPT{database}"); + } +} + my @tables = keys %{$c->{'tables'}}; @tables = qw/$OPT{table}/ if ($OPT{table}); foreach my $t (@tables) { log_info "checking table '$t'"; + if (! $c->{'tables'}->{$t}) { + log_warning("table $t key exists, but no data!"); + remove_table($t); + next; + } my $tc = blessed $c->{'tables'}->{$t}; if ($tc) { if ($tc eq "WAIT::Table") { @@ -305,18 +324,16 @@ log_info("table directory exists"); } else { log_error("can't find directory for table '$t', it should be '$db_dir/$t'"); - if (do_fix("Do you want to remove table '$t' from database?")) { - delete $catalog->{'tables'}->{$t} || die "can't delete table $t from catalog!"; - $cc++; - log_info("table '$t' removed from database $OPT{database}"); - } + remove_table($t); } } else { log_error("table '$t' should be blessed to WAIT::Table and not to $tc!"); + remove_table($t); } } else { log_error("table '$t' isn't blessed"); + remove_table($t); } }