btrbk: fix raw file deletion

pull/427/head
Axel Burri 2021-08-28 13:29:07 +02:00
parent 424127441d
commit 5dc2375a75
1 changed files with 4 additions and 7 deletions

9
btrbk
View File

@ -789,12 +789,13 @@ sub _safe_cmd($$)
foreach(@$aref) { foreach(@$aref) {
if(ref($_) eq 'HASH') { if(ref($_) eq 'HASH') {
my $prefix = $_->{prefix} // ""; my $prefix = $_->{prefix} // "";
my $postfix = $_->{postfix} // "";
$_ = $_->{unsafe}; # replace in-place $_ = $_->{unsafe}; # replace in-place
# NOTE: all files must be absolute (if not, check for leading dash '-' here!) # NOTE: all files must be absolute (if not, check for leading dash '-' here!)
unless(defined(check_file($_, { absolute => 1 }))) { unless(defined(check_file($_, { absolute => 1 }))) {
push @$offending, "\"$_\""; push @$offending, "\"$_\"";
} }
$_ = $prefix . quoteshell($_); $_ = $prefix . quoteshell($_) . $postfix;
} }
} }
return join(' ', @$aref); return join(' ', @$aref);
@ -1445,11 +1446,7 @@ sub btrfs_subvolume_delete($@)
if($target_type eq "raw") { if($target_type eq "raw") {
my @cmd_target_paths; my @cmd_target_paths;
foreach(@$targets) { foreach(@$targets) {
if($_->{node}{BTRBK_RAW}{split}) { push @cmd_target_paths, { unsafe => $_->{PATH}, postfix => ($_->{node}{BTRBK_RAW}{split} && ".split_??") };
push @cmd_target_paths, "$_->{PATH}.split_??"; # unsafe is checked with path.info below
} else {
push @cmd_target_paths, { unsafe => $_->{PATH} };
}
push @cmd_target_paths, { unsafe => "$_->{PATH}.info" }; push @cmd_target_paths, { unsafe => "$_->{PATH}.info" };
} }
$ret = run_cmd(cmd => [ 'rm', '-f', @cmd_target_paths ], $ret = run_cmd(cmd => [ 'rm', '-f', @cmd_target_paths ],