diff options
-rwxr-xr-x | borg-restore.pl | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/borg-restore.pl b/borg-restore.pl index d9fc8e8..038d23b 100755 --- a/borg-restore.pl +++ b/borg-restore.pl @@ -216,6 +216,7 @@ sub select_archive_timespec { sub format_timestamp { my $timestamp = shift; + # FIXME this outputs UTC. fix it to output local time my $dt = DateTime->from_epoch(epoch => $timestamp); return $dt->strftime("%a. %F %H:%M:%S"); } @@ -360,20 +361,21 @@ sub handle_removed_archives { for my $archive (@$remove_archives) { my $archive_index = get_archive_index($archive, $archives); debug(sprintf("Removing archive %s at index %d", $archive, $archive_index)); + assert($archive_index >= 0) if DEBUG; splice @$archives, $archive_index, 1; while (my ($path, $data) = each %db) { # TODO remove archive indexes all at once if (@$data > 0) { - assert($archive_index >= 0) if DEBUG; - assert($archive_index < @$data) if DEBUG; - splice @$data, $archive_index, 1; + if (exists($$data[$archive_index])) { + splice @$data, $archive_index, 1; + $db{$path} = sanitize_db_data($data); + } + if (@$data == 0) { delete $db{$path}; - } else { - $db{$path} = sanitize_db_data($data); - assert(@$data == @$archives) if DEBUG; } + assert(@$data <= @$archives) if DEBUG; } } save_database($archives); |