Add more debugging and event deleting when renumbering

pull/3769/head
Isaac Connor 2023-09-22 16:28:35 -04:00
parent 90caddead6
commit e739b04a97
1 changed files with 6 additions and 1 deletions

View File

@ -120,6 +120,10 @@ foreach my $event_id (@ARGV) {
$event->delete_analysis_jpegs();
} elsif ($command eq 'renumber') {
my $old_path = $event->Path();
if (! -e $old_path) {
Warning("Event $event_id does not exist at $old_path. Skipping renumbering.");
continue;
}
my $new_event = $event->clone();
$new_event->Id(undef);
@ -130,11 +134,12 @@ foreach my $event_id (@ARGV) {
$new_event->RelativePath(undef);
my $new_path = $new_event->Path(undef);
die "New path same as old path $old_path == $new_path!\n" if $old_path eq $new_path;
Debug("Renaming event from $old_path to $new_path");
rename($old_path, $new_path) or die "Failed to rename $old_path to $new_path\n";
zmDbDo('UPDATE Frames SET EventId=? WHERE EventId=?', $new_id, $event_id);
zmDbDo('UPDATE Stats SET EventId=? WHERE EventId=?', $new_id, $event_id);
zmDbDo('UPDATE Event_Data SET EventId=? WHERE EventId=?', $new_id, $event_id);
$event->delete();
}
}