[pve-devel] [PATCH proxmox-backup v3 1/1] file-restore: remove 'json-error' parameter from list_files

Dominik Csapak d.csapak at proxmox.com
Fri May 27 10:22:03 CEST 2022


we can reuse the 'output_format' here
also remove the 'error: true' here. we can determine it was an error,
by checking if it's an object with a 'message' property

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 proxmox-file-restore/src/main.rs | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/proxmox-file-restore/src/main.rs b/proxmox-file-restore/src/main.rs
index 3420ea8e..ee5b5b9c 100644
--- a/proxmox-file-restore/src/main.rs
+++ b/proxmox-file-restore/src/main.rs
@@ -217,12 +217,6 @@ async fn list_files(
                 schema: OUTPUT_FORMAT,
                 optional: true,
             },
-            "json-error": {
-                type: Boolean,
-                description: "If set, errors are returned as json instead of writing to stderr",
-                optional: true,
-                default: false,
-            },
             "timeout": {
                 type: Integer,
                 description: "Defines the maximum time the call can should take.",
@@ -245,7 +239,6 @@ async fn list(
     snapshot: String,
     path: String,
     base64: bool,
-    json_error: bool,
     timeout: Option<u64>,
     param: Value,
 ) -> Result<(), Error> {
@@ -290,7 +283,7 @@ async fn list(
     let output_format = get_output_format(&param);
 
     if let Err(err) = result {
-        if !json_error {
+        if &output_format == "text" {
             return Err(err);
         }
         let (msg, code) = match err.downcast_ref::<HttpError>() {
@@ -298,7 +291,6 @@ async fn list(
             None => (err.to_string(), None),
         };
         let mut json_err = json!({
-            "error": true,
             "message": msg,
         });
         if let Some(code) = code {
-- 
2.30.2





More information about the pve-devel mailing list