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 B181A9C186 for ; Tue, 21 Nov 2023 17:21:49 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 93390D6BF for ; Tue, 21 Nov 2023 17:21:19 +0100 (CET) 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 for ; Tue, 21 Nov 2023 17:21:19 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id CA99441D84 for ; Tue, 21 Nov 2023 17:21:18 +0100 (CET) From: Stefan Lendl To: pbs-devel@lists.proxmox.com Date: Tue, 21 Nov 2023 17:21:09 +0100 Message-ID: <20231121162111.537833-2-s.lendl@proxmox.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231121162111.537833-1-s.lendl@proxmox.com> References: <20231121162111.537833-1-s.lendl@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.004 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment PROLO_LEO1 0.1 Meta Catches all Leo drug variations so far SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [PATCH v2 proxmox-backup 1/3] prune job: prune job creation in separate function 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 Nov 2023 16:21:49 -0000 move logic for prune job creation to do_create_prune_job Signed-off-by: Stefan Lendl --- src/api2/config/prune.rs | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/api2/config/prune.rs b/src/api2/config/prune.rs index 6f391722..1e8b5526 100644 --- a/src/api2/config/prune.rs +++ b/src/api2/config/prune.rs @@ -56,6 +56,24 @@ pub fn list_prune_jobs( Ok(list) } +pub fn do_create_prune_job(config: PruneJobConfig) -> Result<(), Error> { + let _lock = prune::lock_config()?; + + let (mut section_config, _digest) = prune::config()?; + + if section_config.sections.get(&config.id).is_some() { + param_bail!("id", "job '{}' already exists.", config.id); + } + + section_config.set_data(&config.id, "prune", &config)?; + + prune::save_config(§ion_config)?; + + crate::server::jobstate::create_state_file("prunejob", &config.id)?; + + Ok(()) +} + #[api( protected: true, input: { @@ -81,21 +99,7 @@ pub fn create_prune_job( user_info.check_privs(&auth_id, &config.acl_path(), PRIV_DATASTORE_MODIFY, true)?; - let _lock = prune::lock_config()?; - - let (mut section_config, _digest) = prune::config()?; - - if section_config.sections.get(&config.id).is_some() { - param_bail!("id", "job '{}' already exists.", config.id); - } - - section_config.set_data(&config.id, "prune", &config)?; - - prune::save_config(§ion_config)?; - - crate::server::jobstate::create_state_file("prunejob", &config.id)?; - - Ok(()) + do_create_prune_job(config) } #[api( -- 2.42.0