[pbs-devel] [PATCH proxmox-backup v5 7/8] datastore: avoid tuple-match, use plain if
Hannes Laimer
h.laimer at proxmox.com
Mon Jan 24 13:31:58 CET 2022
From: Thomas Lamprecht <t.lamprecht at proxmox.com>
and render the offline/read-only errors differently
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
---
pbs-datastore/src/datastore.rs | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index 774dea80..c643bc55 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -101,13 +101,15 @@ impl DataStore {
let config: DataStoreConfig = config.lookup("datastore", name)?;
let path = PathBuf::from(&config.path);
- match (&config.maintenance_type, operation) {
- (Some(MaintenanceType::ReadOnly(message)), Some(Operation::Write))
- | (Some(MaintenanceType::Offline(message)), Some(_)) => {
- bail!("Datastore '{}' is in maintenance mode: {}", name, message);
- },
- (_, Some(operation)) => update_active_operations(name, operation, 1)?,
- _ => {}
+ if let Some(MaintenanceType::Offline(message)) = &config.maintenance_type {
+ bail!("datastore '{}' is in offline maintenance mode: {}", name, message);
+ } else if let Some(MaintenanceType::ReadOnly(message)) = &config.maintenance_type {
+ if let Some(Operation::Write) = operation {
+ bail!("datastore '{}' is in read-only maintenance mode: {}", name, message);
+ }
+ }
+ if let Some(op) = operation {
+ update_active_operations(name, op, 1)?;
}
let mut map = DATASTORE_MAP.lock().unwrap();
--
2.30.2
More information about the pbs-devel
mailing list