summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;
}