From fd18775ac17a5bc9bafc3e5a6be37f1757a77a5b Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 21 Sep 2021 07:58:54 +0200 Subject: [PATCH] worker_state: move tasktype() code to src/api2/node/tasks.rs Because this is API related code, and only used there. Signed-off-by: Thomas Lamprecht --- src/api2/node/tasks.rs | 11 ++++++++++- src/server/worker_task.rs | 11 +---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/api2/node/tasks.rs b/src/api2/node/tasks.rs index 9aaf6f1a..7066f889 100644 --- a/src/api2/node/tasks.rs +++ b/src/api2/node/tasks.rs @@ -116,6 +116,15 @@ fn check_task_access(auth_id: &Authid, upid: &UPID) -> Result<(), Error> { } } +pub fn tasktype(state: &TaskState) -> TaskStateType { + match state { + TaskState::OK { .. } => TaskStateType::OK, + TaskState::Unknown { .. } => TaskStateType::Unknown, + TaskState::Error { .. } => TaskStateType::Error, + TaskState::Warning { .. } => TaskStateType::Warning, + } +} + #[api( input: { properties: { @@ -492,7 +501,7 @@ pub fn list_tasks( (Some(_), _) if running => continue, (Some(crate::server::TaskState::OK { .. }), _) if errors => continue, (Some(state), Some(filters)) => { - if !filters.contains(&state.tasktype()) { + if !filters.contains(&tasktype(state)) { continue; } }, diff --git a/src/server/worker_task.rs b/src/server/worker_task.rs index c62ba7df..565ce154 100644 --- a/src/server/worker_task.rs +++ b/src/server/worker_task.rs @@ -18,7 +18,7 @@ use proxmox::tools::fs::{create_path, replace_file, CreateOptions}; use pbs_buildcfg; use pbs_tools::logrotate::{LogRotate, LogRotateFiles}; -use pbs_api_types::{Authid, TaskStateType, UPID}; +use pbs_api_types::{Authid, UPID}; use pbs_config::{open_backup_lockfile, BackupLockGuard}; use proxmox_rest_server::{CommandoSocket, FileLogger, FileLogOptions}; @@ -243,15 +243,6 @@ impl TaskState { } } - pub fn tasktype(&self) -> TaskStateType { - match self { - TaskState::OK { .. } => TaskStateType::OK, - TaskState::Unknown { .. } => TaskStateType::Unknown, - TaskState::Error { .. } => TaskStateType::Error, - TaskState::Warning { .. } => TaskStateType::Warning, - } - } - fn result_text(&self) -> String { match self { TaskState::Error { message, .. } => format!("TASK ERROR: {}", message),