]> git.proxmox.com Git - pve-storage.git/commitdiff
file-restore: return perl-y booleans
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Fri, 23 Apr 2021 10:34:25 +0000 (12:34 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 23 Apr 2021 12:09:54 +0000 (14:09 +0200)
like we do in most of our API.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
PVE/API2/Storage/FileRestore.pm

index 68f81ebe1e31acc125be6d99afe4f268aeabcb74..f6dc74abc999e217cf8cbd435c54114a9ce1f10f 100644 (file)
@@ -56,7 +56,7 @@ __PACKAGE__->register_method ({
                },
                leaf => {
                    description => "If this entry is a leaf in the directory graph.",
-                   type => 'any', # JSON::PP::Boolean gets passed through
+                   type => 'boolean',
                },
                size => {
                    description => "Entry file size.",
@@ -91,6 +91,13 @@ __PACKAGE__->register_method ({
        my $client = PVE::PBSClient->new($scfg, $storeid);
        my $ret = $client->file_restore_list($snap, $path, $base64);
 
+
+       # 'leaf' is a proper JSON boolean, map to perl-y bool
+       # TODO: make PBSClient decode all bools always as 1/0?
+       foreach my $item (@$ret) {
+           $item->{leaf} = $item->{leaf} ? 1 : 0;
+       }
+
        return $ret;
     }});