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 9B8B191948 for ; Thu, 2 Feb 2023 14:04:31 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7AAECCE7E for ; Thu, 2 Feb 2023 14:04:31 +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 ; Thu, 2 Feb 2023 14:04:30 +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 AA83C408FC for ; Thu, 2 Feb 2023 14:04:30 +0100 (CET) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pbs-devel@lists.proxmox.com Date: Thu, 2 Feb 2023 14:04:23 +0100 Message-Id: <20230202130424.3446075-1-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.127 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. [mod.rs] Subject: [pbs-devel] [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: Thu, 02 Feb 2023 13:04:31 -0000 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