From 07b6db80993b08d1e0533dd180c7b2924c1acf14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Thu, 2 Feb 2023 14:04:23 +0100 Subject: [PATCH] backup/snapshot reader: improve error message for ENOENT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- 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",