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),