From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 4D1906B84B for ; Tue, 21 Sep 2021 07:59:34 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 06F6F8FAC for ; Tue, 21 Sep 2021 07:59:03 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 959018E4F for ; Tue, 21 Sep 2021 07:58:59 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 7047E449E1; Tue, 21 Sep 2021 07:58:59 +0200 (CEST) From: Dietmar Maurer To: pbs-devel@lists.proxmox.com Date: Tue, 21 Sep 2021 07:58:54 +0200 Message-Id: <20210921055854.3799470-17-dietmar@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210921055854.3799470-1-dietmar@proxmox.com> References: <20210921055854.3799470-1-dietmar@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.606 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [tasks.rs] Subject: [pbs-devel] [PATCH proxmox-backup v2 16/16] worker_state: move tasktype() code to src/api2/node/tasks.rs X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Sep 2021 05:59:34 -0000 Because this is API related code, and only used there. --- 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), -- 2.30.2