summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2016-08-14 15:00:48 +0200
committerFlorian Pritz <bluewind@xinu.at>2016-08-14 15:00:48 +0200
commit8ff5652f8a640862a5a667ce3d21eafa7d537552 (patch)
treeb1a50d77c0ab253a9694c9362381b09ca8af8e19
parentbcc838d24280a38dcede58773860275d98e744c5 (diff)
downloadbin-8ff5652f8a640862a5a667ce3d21eafa7d537552.tar.gz
bin-8ff5652f8a640862a5a667ce3d21eafa7d537552.tar.xz
borg-restore.pl: Fix deletion of old db entries
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-xborg-restore.pl14
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);