summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2016-08-14 15:50:28 +0200
committerFlorian Pritz <bluewind@xinu.at>2016-08-14 15:52:06 +0200
commitf38ea4f75d4a44859b9a1c7ae56c1ebee1ab37e4 (patch)
tree6a77ccb684eccda4917f610bb70d99bda7961212
parent8ff5652f8a640862a5a667ce3d21eafa7d537552 (diff)
downloadbin-f38ea4f75d4a44859b9a1c7ae56c1ebee1ab37e4.tar.gz
bin-f38ea4f75d4a44859b9a1c7ae56c1ebee1ab37e4.tar.xz
borg-restore.pl: misc
- switch back to undef instead of -1 - fix incorrect assertion - clean up path before resolving Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-xborg-restore.pl21
1 files changed, 15 insertions, 6 deletions
diff --git a/borg-restore.pl b/borg-restore.pl
index 038d23b..ba4998c 100755
--- a/borg-restore.pl
+++ b/borg-restore.pl
@@ -87,6 +87,7 @@ use File::Basename;
use File::Copy;
use File::Path qw(mkpath);
use File::Slurp;
+use File::Spec;
use File::Temp;
use Getopt::Long;
use IO::Compress::Gzip qw($GzipError);
@@ -398,7 +399,7 @@ sub sanitize_db_data {
if (defined($item)) {
push @ret, $item + 0;
} else {
- push @ret, -1;
+ push @ret, undef;
}
}
@@ -554,7 +555,7 @@ sub get_mtime_from_lookuptable {
for my $component (@components) {
$node = $$node[0]->{$component};
if (!defined($node)) {
- return -1;
+ return undef;
}
}
return $$node[1];
@@ -564,12 +565,12 @@ sub clean_db {
my $archives = shift;
while (my ($path, $data) = each %db) {
- # check if data is empty or all fields in data are -1
- if (!@$data || all { $_ != -1 } @$data) {
+ # check if data is empty or all fields in data are undef
+ if (!@$data || all { !defined($_) } @$data) {
debug("Deleting path because it's not part of any archive: ", $path);
delete $db{$path};
}
- assert(@$data == @$archives) if DEBUG;
+ assert(@$data <= @$archives) if DEBUG;
}
}
@@ -621,7 +622,15 @@ sub main {
exit(1);
}
- my $abs_path = abs_path($path);
+ my $canon_path = File::Spec->canonpath($path);
+ my $abs_path = abs_path($canon_path);
+ print Dumper($abs_path, $path, $canon_path);
+ if (!defined($abs_path)) {
+ say STDERR "Error: Failed to resolve path to absolute path: $canon_path: $!";
+ say STDERR "Make sure that all parts of the path, except the last one, exist.";
+ exit(1);
+ }
+
if (!defined($destination)) {
$destination = $abs_path;
}