]> git.proxmox.com Git - pve-storage.git/commitdiff
config: use relative paths for content overrides
authorLeo Nunner <l.nunner@proxmox.com>
Tue, 14 Mar 2023 13:14:54 +0000 (14:14 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 20 Mar 2023 13:30:43 +0000 (14:30 +0100)
Remove the requirement for paths to start with a /, as it might be
confusing to users.

Signed-off-by: Leo Nunner <l.nunner@proxmox.com>
PVE/Storage/Plugin.pm
test/get_subdir_test.pm

index 2c5ba536173cb05d6e5ef3587160a0236615f9ec..09f6ad215f0eada9410d47d3ea613dacfc380382 100644 (file)
@@ -355,7 +355,7 @@ PVE::JSONSchema::register_format('pve-dir-override', \&verify_dir_override);
 sub verify_dir_override {
     my ($value, $noerr) = @_;
 
-    if ($value =~ m/^([-a-z]+)=\/.+$/ && verify_content($1, $noerr)) {
+    if ($value =~ m/^([a-z]+)=[^.]+$/ && verify_content($1, $noerr)) {
        return $value;
     }
 
@@ -658,9 +658,9 @@ sub get_subdir {
     die "storage definition has no path\n" if !$path;
     die "unknown vtype '$vtype'\n" if !exists($vtype_subdirs->{$vtype});
 
-    my $subdir = $scfg->{"content-dirs"}->{$vtype} // "/".$vtype_subdirs->{$vtype};
+    my $subdir = $scfg->{"content-dirs"}->{$vtype} // $vtype_subdirs->{$vtype};
 
-    return $path.$subdir;
+    return "$path/$subdir";
 }
 
 sub filesystem_path {
index ff42985bb783d049011cf405fac196d0e88be912..b9d61d5050d2e17a8068813def7b7a3bc90b20c9 100644 (file)
@@ -29,9 +29,9 @@ foreach my $type (keys %$vtype_subdirs) {
 
 # creates additional tests for overrides
 foreach my $type (keys %$vtype_subdirs) {
-    my $override = "/${type}_override";
+    my $override = "${type}_override";
     my $scfg_with_override = { path => '/some/path', 'content-dirs' => { $type => $override } };
-    push @$tests, [ $scfg_with_override, $type, "$scfg_with_override->{path}$scfg_with_override->{'content-dirs'}->{$type}" ];
+    push @$tests, [ $scfg_with_override, $type, "$scfg_with_override->{path}/$scfg_with_override->{'content-dirs'}->{$type}" ];
 }
 
 plan tests => scalar @$tests;