[pbs-devel] [PATCH proxmox 1/2] pbs-api-types: make operation non-optional for maintenance-mode check

Christian Ebner c.ebner at proxmox.com
Thu Jan 22 16:11:20 CET 2026


This checks the availability of the datastore constrained by the
currently set maintenance-mode, based on the operation the caller
would like to perform.

In an effort to force the operation to be set when performing
datastore operations, make this non optional for the maintenance mode
checks.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
 pbs-api-types/src/maintenance.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pbs-api-types/src/maintenance.rs b/pbs-api-types/src/maintenance.rs
index 6b97ff10..5af34291 100644
--- a/pbs-api-types/src/maintenance.rs
+++ b/pbs-api-types/src/maintenance.rs
@@ -93,7 +93,7 @@ impl MaintenanceMode {
             || self.ty == MaintenanceType::Unmount
     }
 
-    pub fn check(&self, operation: Option<Operation>) -> Result<(), Error> {
+    pub fn check(&self, operation: Operation) -> Result<(), Error> {
         if self.ty == MaintenanceType::Delete {
             bail!("datastore is being deleted");
         }
@@ -102,7 +102,7 @@ impl MaintenanceMode {
             .decode_utf8()
             .unwrap_or(Cow::Borrowed(""));
 
-        if let Some(Operation::Lookup) = operation {
+        if Operation::Lookup == operation {
             return Ok(());
         } else if self.ty == MaintenanceType::Unmount {
             bail!("datastore is being unmounted");
@@ -111,7 +111,7 @@ impl MaintenanceMode {
         } else if self.ty == MaintenanceType::S3Refresh {
             bail!("S3 refresh maintenance mode: {}", message);
         } else if self.ty == MaintenanceType::ReadOnly {
-            if let Some(Operation::Write) = operation {
+            if Operation::Write == operation {
                 bail!("read-only maintenance mode: {}", message);
             }
         }
-- 
2.47.3





More information about the pbs-devel mailing list