mirror of
git://git.proxmox.com/git/pve-storage.git
synced 2024-12-22 13:34:16 +03:00
file size info: introduce error handling helper
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
parent
4836e98901
commit
10d338baa8
@ -971,6 +971,16 @@ sub file_size_info {
|
||||
}
|
||||
}
|
||||
|
||||
my $handle_error = sub {
|
||||
my ($msg) = @_;
|
||||
if ($untrusted) {
|
||||
die $msg;
|
||||
} else {
|
||||
warn $msg;
|
||||
return wantarray ? (undef, undef, undef, undef, $st->ctime) : undef;
|
||||
}
|
||||
};
|
||||
|
||||
if (S_ISDIR($st->mode)) {
|
||||
return wantarray ? (0, 'subvol', 0, undef, $st->ctime) : 1;
|
||||
}
|
||||
@ -998,15 +1008,7 @@ sub file_size_info {
|
||||
}
|
||||
|
||||
my $info = eval { decode_json($json) };
|
||||
if (my $err = $@) {
|
||||
my $msg = "could not parse qemu-img info command output for '$filename' - $err\n";
|
||||
if ($untrusted) {
|
||||
die $msg;
|
||||
} else {
|
||||
warn $msg;
|
||||
return wantarray ? (undef, undef, undef, undef, $st->ctime) : undef;
|
||||
}
|
||||
}
|
||||
$handle_error->("could not parse qemu-img info command output for '$filename' - $@\n") if $@;
|
||||
|
||||
if ($untrusted) {
|
||||
if (my $format_specific = $info->{'format-specific'}) {
|
||||
|
Loading…
Reference in New Issue
Block a user