From 6d04612955518f22db221f8bd674cfd4f2f36c6b Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 11 Dec 2019 10:52:27 +0100 Subject: [PATCH] src/api2/node/tasks.rs: add "running" filter to list only running tasks --- src/api2/node/tasks.rs | 3 +++ src/bin/proxmox-backup-client.rs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/api2/node/tasks.rs b/src/api2/node/tasks.rs index f2559a8c..bb8b6b7b 100644 --- a/src/api2/node/tasks.rs +++ b/src/api2/node/tasks.rs @@ -124,6 +124,7 @@ fn list_tasks( let start = param["start"].as_u64().unwrap_or(0); let limit = param["limit"].as_u64().unwrap_or(50); let errors = param["errors"].as_bool().unwrap_or(false); + let running = param["running"].as_bool().unwrap_or(false); let userfilter = param["userfilter"].as_str(); @@ -150,6 +151,7 @@ fn list_tasks( } if let Some(ref state) = info.state { + if running { continue; } if errors && state.1 == "OK" { continue; } @@ -259,6 +261,7 @@ pub const ROUTER: Router = Router::new() .default(50) .schema() ), + ("running", true, &BooleanSchema::new("Only list running tasks.").schema()), ("errors", true, &BooleanSchema::new("Only list erroneous tasks.").schema()), ("userfilter", true, &StringSchema::new("Only list tasks from this user.").schema()), ]), diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs index f84d8b2f..6f4b6880 100644 --- a/src/bin/proxmox-backup-client.rs +++ b/src/bin/proxmox-backup-client.rs @@ -1980,7 +1980,7 @@ fn task_list(param: Value) -> Result { let limit = param["limit"].as_u64().unwrap_or(50) as usize; - let args = json!({ "start": 0, "limit": limit, "userfilter": repo.user()}); + let args = json!({ "running": true, "start": 0, "limit": limit, "userfilter": repo.user()}); let result = client.get("api2/json/nodes/localhost/tasks", Some(args)).await?; let data = &result["data"];