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 9519F9189C for ; Wed, 8 Feb 2023 15:22:57 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 748C118F3B for ; Wed, 8 Feb 2023 15:22:27 +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 ; Wed, 8 Feb 2023 15:22:26 +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 7E761460E3 for ; Wed, 8 Feb 2023 15:22:26 +0100 (CET) Date: Wed, 8 Feb 2023 15:22:25 +0100 From: Wolfgang Bumiller To: Fabian =?utf-8?Q?Gr=C3=BCnbichler?= Cc: pbs-devel@lists.proxmox.com Message-ID: <20230208142225.k4dcf572ittzozze@fwblub> References: <20230202130424.3446075-1-f.gruenbichler@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230202130424.3446075-1-f.gruenbichler@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.190 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 Subject: [pbs-devel] applied-series: [PATCH proxmox-backup 1/2] backup/snapshot reader: improve error message for ENOENT 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, 08 Feb 2023 14:22:57 -0000 While I really do not like `.exists()` on a path that is used right afterwards and our "helpers" there need to switch to `io::Error` instead of useless `anyhow::Error` strings... expecting our locking to change and the paths don't matching up afterwards this series should be fine this way, too. applied, thanks On Thu, Feb 02, 2023 at 02:04:23PM +0100, Fabian Grünbichler wrote: > instead of > > Error: unable to open snapshot directory "/full/path/to/snapshot" for locking - ENOENT: No such file or directory > > this will now print > > Error: Snapshot vm/800/2023-01-16T12:28:11Z does not exist. > > Signed-off-by: Fabian Grünbichler > --- > > Notes: > we could also include the datastore/namespace, although we are not that > consistent in general in that regard, and the caller should technically > know since they provided it ;). > > pbs-datastore/src/snapshot_reader.rs | 4 ++++ > src/api2/reader/mod.rs | 4 ++++ > 2 files changed, 8 insertions(+) > > diff --git a/pbs-datastore/src/snapshot_reader.rs b/pbs-datastore/src/snapshot_reader.rs > index 899c3bce..ec7a48e5 100644 > --- a/pbs-datastore/src/snapshot_reader.rs > +++ b/pbs-datastore/src/snapshot_reader.rs > @@ -41,6 +41,10 @@ impl SnapshotReader { > let datastore = snapshot.datastore(); > let snapshot_path = snapshot.full_path(); > > + if !snapshot_path.exists() { > + bail!("snapshot {} does not exist!", snapshot.dir()); > + } > + > let locked_dir = > lock_dir_noblock_shared(&snapshot_path, "snapshot", "locked by another operation")?; > > diff --git a/src/api2/reader/mod.rs b/src/api2/reader/mod.rs > index e2a10da3..1ac4ac40 100644 > --- a/src/api2/reader/mod.rs > +++ b/src/api2/reader/mod.rs > @@ -125,6 +125,10 @@ fn upgrade_to_backup_reader_protocol( > } > } > > + if !backup_dir.full_path().exists() { > + bail!("snapshot {} does not exist.", backup_dir.dir()); > + } > + > let _guard = lock_dir_noblock_shared( > &backup_dir.full_path(), > "snapshot", > -- > 2.30.2