server/worker_task: add tasktype to return the api type of a taskstate

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2020-10-30 15:02:10 +01:00 committed by Thomas Lamprecht
parent 038ee59960
commit fa31f4c54c
1 changed files with 10 additions and 1 deletions

View File

@ -22,7 +22,7 @@ use crate::buildcfg;
use crate::server; use crate::server;
use crate::tools::logrotate::{LogRotate, LogRotateFiles}; use crate::tools::logrotate::{LogRotate, LogRotateFiles};
use crate::tools::{FileLogger, FileLogOptions}; use crate::tools::{FileLogger, FileLogOptions};
use crate::api2::types::Authid; use crate::api2::types::{Authid, TaskStateType};
macro_rules! taskdir { macro_rules! taskdir {
($subdir:expr) => (concat!(PROXMOX_BACKUP_LOG_DIR_M!(), "/tasks", $subdir)) ($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 { fn result_text(&self) -> String {
match self { match self {
TaskState::Error { message, .. } => format!("TASK ERROR: {}", message), TaskState::Error { message, .. } => format!("TASK ERROR: {}", message),