]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage.pm
zfspool: add zfs_get_sorted_snapshot_list helper
[pve-storage.git] / PVE / Storage.pm
index a024953982a2e2e1072b77b1798ed405b8365985..71d6ad78db1255286c64d48549f10894011b9094 100755 (executable)
@@ -103,7 +103,7 @@ PVE::Storage::Plugin->init();
 
 our $iso_extension_re = qr/\.(?:iso|img)/i;
 
-our $vztmpl_extension_re = qr/\.tar\.([gx]z)/i;
+our $vztmpl_extension_re = qr/\.tar\.(gz|xz|zst)/i;
 
 #  PVE::Storage utility functions
 
@@ -692,7 +692,7 @@ sub storage_migrate {
 
     my $migration_snapshot;
     if (!defined($snapshot)) {
-       if ($scfg->{type} eq 'zfspool') {
+       if ($scfg->{type} eq 'zfspool' || $scfg->{type} eq 'btrfs') {
            $migration_snapshot = 1;
            $snapshot = '__migration__';
        }
@@ -1560,7 +1560,7 @@ sub extract_vzdump_config_vma {
        my $errstring;
        my $err = sub {
            my $output = shift;
-           if ($output =~ m/lzop: Broken pipe: <stdout>/ || $output =~ m/gzip: stdout: Broken pipe/ || $output =~ m/zstd: error 70 : Write error : Broken pipe/) {
+           if ($output =~ m/lzop: Broken pipe: <stdout>/ || $output =~ m/gzip: stdout: Broken pipe/ || $output =~ m/zstd: error 70 : Write error.*Broken pipe/) {
                $broken_pipe = 1;
            } elsif (!defined ($errstring) && $output !~ m/^\s*$/) {
                $errstring = "Failed to extract config from VMA archive: $output\n";
@@ -1666,10 +1666,9 @@ my $prune_mark = sub {
 sub prune_mark_backup_group {
     my ($backup_group, $keep) = @_;
 
-    my $keep_all = delete $keep->{'keep-all'};
+    my @positive_opts = grep { $_ ne 'keep-all' && $keep->{$_} > 0 } keys $keep->%*;
 
-    if ($keep_all || !scalar(grep {$_ > 0} values %{$keep})) {
-       $keep = { 'keep-all' => 1 } if $keep_all;
+    if ($keep->{'keep-all'} || scalar(@positive_opts) == 0) {
        foreach my $prune_entry (@{$backup_group}) {
            $prune_entry->{mark} = 'keep';
        }
@@ -1945,4 +1944,16 @@ sub assert_sid_unused {
     return undef;
 }
 
+# removes leading/trailing spaces and (back)slashes completely
+# substitutes every non-ASCII-alphanumerical char with '_', except '_.-'
+sub normalize_content_filename {
+    my ($filename) = @_;
+
+    chomp $filename;
+    $filename =~ s/^.*[\/\\]//;
+    $filename =~ s/[^a-zA-Z0-9_.-]/_/g;
+
+    return $filename;
+}
+
 1;