From fa31f4c54c50cc00cfc86463402c859b29f05557 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Fri, 30 Oct 2020 15:02:10 +0100 Subject: [PATCH] server/worker_task: add tasktype to return the api type of a taskstate Signed-off-by: Dominik Csapak --- src/server/worker_task.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/server/worker_task.rs b/src/server/worker_task.rs index ff853058..24b4e3d6 100644 --- a/src/server/worker_task.rs +++ b/src/server/worker_task.rs @@ -22,7 +22,7 @@ use crate::buildcfg; use crate::server; use crate::tools::logrotate::{LogRotate, LogRotateFiles}; use crate::tools::{FileLogger, FileLogOptions}; -use crate::api2::types::Authid; +use crate::api2::types::{Authid, TaskStateType}; macro_rules! taskdir { ($subdir:expr) => (concat!(PROXMOX_BACKUP_LOG_DIR_M!(), "/tasks", $subdir)) @@ -242,6 +242,15 @@ 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),