From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 3E7FD1FF165 for ; Thu, 6 Nov 2025 10:37:21 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3316A11CDB; Thu, 6 Nov 2025 10:38:02 +0100 (CET) Date: Thu, 06 Nov 2025 10:37:56 +0100 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox Backup Server development discussion References: <20251105122233.439382-1-c.ebner@proxmox.com> <20251105122233.439382-4-c.ebner@proxmox.com> In-Reply-To: <20251105122233.439382-4-c.ebner@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.17.0 (https://github.com/astroidmail/astroid) Message-Id: <1762416758.0bue1durd4.astroid@yuna.none> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1762421860521 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.048 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pbs-devel] [PATCH proxmox-backup v3 03/23] api/datastore: move snapshot deletion into dedicated datastore helper 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: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" On November 5, 2025 1:22 pm, Christian Ebner wrote: > In an effort to move all datastore backend related logic to the > datastore itself. should we then make BackupDir::destroy pub(crate)? > > Signed-off-by: Christian Ebner > --- > changes since version 2: > - no changes > > pbs-datastore/src/datastore.rs | 9 +++++++++ > src/api2/admin/datastore.rs | 25 ++++++++----------------- > 2 files changed, 17 insertions(+), 17 deletions(-) > > diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs > index 45f315aeb..46600a88c 100644 > --- a/pbs-datastore/src/datastore.rs > +++ b/pbs-datastore/src/datastore.rs > @@ -2444,4 +2444,13 @@ impl DataStore { > .context("failed to replace group notes file")?; > Ok(()) > } > + > + /// Delete a backup snapshot from the datastore. > + /// Acquires exclusive lock on the backup snapshot. > + pub fn delete_snapshot(self: &Arc, snapshot: &BackupDir) -> Result<(), Error> { > + let backend = self.backend().context("failed to get backend")?; > + // acquires exclusive lock on snapshot before removal > + snapshot.destroy(false, &backend)?; > + Ok(()) > + } > } > diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs > index 131cdae51..763440df9 100644 > --- a/src/api2/admin/datastore.rs > +++ b/src/api2/admin/datastore.rs > @@ -378,9 +378,9 @@ pub async fn delete_snapshot( > )?; > > let snapshot = datastore.backup_dir(ns, backup_dir)?; > - > - snapshot.destroy(false, &datastore.backend()?)?; > - > + datastore > + .delete_snapshot(&snapshot) > + .map_err(|err| format_err!("failed to delete snapshot - {err:#?}"))?; > Ok(Value::Null) > }) > .await? > @@ -986,21 +986,12 @@ pub fn prune( > }); > > if !keep { > - match datastore.backend() { > - Ok(backend) => { > - if let Err(err) = backup_dir.destroy(false, &backend) { > - warn!( > - "failed to remove dir {:?}: {}", > - backup_dir.relative_path(), > - err, > - ); > - } > - } > - Err(err) => warn!( > - "failed to remove dir {:?}: {err}", > + if let Err(err) = datastore.delete_snapshot(backup_dir) { > + warn!( > + "failed to remove dir {:?}: {err:#?}", > backup_dir.relative_path() > - ), > - }; > + ); > + } > } > } > prune_result > -- > 2.47.3 > > > > _______________________________________________ > pbs-devel mailing list > pbs-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel > > > _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel