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 30167D3C2 for ; Wed, 30 Nov 2022 16:01:29 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 182BF200F9 for ; Wed, 30 Nov 2022 16:01:29 +0100 (CET) Received: from lana.proxmox.com (unknown [94.136.29.99]) by firstgate.proxmox.com (Proxmox) with ESMTP for ; Wed, 30 Nov 2022 16:01:28 +0100 (CET) Received: by lana.proxmox.com (Postfix, from userid 10043) id CFC1A2C2788; Wed, 30 Nov 2022 16:01:26 +0100 (CET) From: Stefan Hanreich To: pbs-devel@lists.proxmox.com Date: Wed, 30 Nov 2022 16:01:00 +0100 Message-Id: <20221130150102.242374-6-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221130150102.242374-1-s.hanreich@proxmox.com> References: <20221130150102.242374-1-s.hanreich@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.321 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 KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods NO_DNS_FOR_FROM 0.001 Envelope sender has no MX or A DNS records RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pbs-devel] [PATCH proxmox-backup v2 5/7] use new PruneJob struct in Prune Jobs implementation 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: Wed, 30 Nov 2022 15:01:29 -0000 Refactor Prune Jobs to utilize the newly created PruneJob struct instead of manually computing the prune_info and executing the prune task. Signed-off-by: Stefan Hanreich --- src/server/prune_job.rs | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/src/server/prune_job.rs b/src/server/prune_job.rs index b9f7ebdf..0999ea6c 100644 --- a/src/server/prune_job.rs +++ b/src/server/prune_job.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use anyhow::Error; -use proxmox_sys::{task_log, task_warn}; +use proxmox_sys::task_log; use pbs_api_types::{ print_store_and_ns, Authid, KeepOptions, Operation, PruneJobOptions, MAX_NAMESPACE_DEPTH, @@ -58,9 +58,6 @@ pub fn prune_datastore( let ns = group.backup_ns(); let list = group.list_backups()?; - let mut prune_info = PruneJob::compute_prune_info(list, &prune_options.keep)?; - prune_info.reverse(); // delete older snapshots first - task_log!( worker, "Pruning group {ns}:\"{}/{}\"", @@ -68,24 +65,10 @@ pub fn prune_datastore( group.backup_id() ); - for (info, mark) in prune_info { - let keep = keep_all || mark.keep(); - task_log!( - worker, - "{}{} {}/{}/{}", - if dry_run { "would " } else { "" }, - mark, - group.backup_type(), - group.backup_id(), - info.backup_dir.backup_time_string() - ); - if !keep && !dry_run { - if let Err(err) = datastore.remove_backup_dir(ns, info.backup_dir.as_ref(), false) { - let path = info.backup_dir.relative_path(); - task_warn!(worker, "failed to remove dir {path:?}: {err}"); - } - } - } + PruneJob::new(list, &prune_options.keep)? + .dry_run(dry_run) + .logging(worker.clone()) + .run(); } Ok(()) -- 2.30.2