From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 1/2] backup/snapshot reader: improve error message for ENOENT
Date: Thu, 2 Feb 2023 14:04:23 +0100 [thread overview]
Message-ID: <20230202130424.3446075-1-f.gruenbichler@proxmox.com> (raw)
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 <f.gruenbichler@proxmox.com>
---
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
next reply other threads:[~2023-02-02 13:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 13:04 Fabian Grünbichler [this message]
2023-02-02 13:04 ` [pbs-devel] [PATCH proxmox-backup 2/2] verify/protect: improve error on disappearing snapshots Fabian Grünbichler
2023-02-08 14:22 ` [pbs-devel] applied-series: [PATCH proxmox-backup 1/2] backup/snapshot reader: improve error message for ENOENT Wolfgang Bumiller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230202130424.3446075-1-f.gruenbichler@proxmox.com \
--to=f.gruenbichler@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.