[pbs-devel] [PATCH proxmox-backup 3/5] api2: disks/directory: refactor BASE_MOUNT_DIR

Dominik Csapak d.csapak at proxmox.com
Thu Sep 9 15:48:17 CEST 2021


Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/api2/node/disks/directory.rs | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/api2/node/disks/directory.rs b/src/api2/node/disks/directory.rs
index 0cb6f4e2..dd6912d3 100644
--- a/src/api2/node/disks/directory.rs
+++ b/src/api2/node/disks/directory.rs
@@ -22,6 +22,8 @@ use crate::server::WorkerTask;
 use crate::config::datastore::{self, DataStoreConfig};
 use pbs_config::open_backup_lockfile;
 
+const BASE_MOUNT_DIR: &str = "/mnt/datastore/";
+
 #[api(
     properties: {
         "filesystem": {
@@ -146,7 +148,7 @@ pub fn create_datastore_disk(
         bail!("disk '{}' is already in use.", disk);
     }
 
-    let mount_point = format!("/mnt/datastore/{}", &name);
+    let mount_point = format!("{}{}", BASE_MOUNT_DIR, &name);
 
     // check if the default path does exist already and bail if it does
     let default_path = std::path::PathBuf::from(&mount_point);
@@ -221,7 +223,7 @@ pub fn create_datastore_disk(
 /// Remove a Filesystem mounted under '/mnt/datastore/<name>'.".
 pub fn delete_datastore_disk(name: String) -> Result<(), Error> {
 
-    let path = format!("/mnt/datastore/{}", name);
+    let path = format!("{}{}", BASE_MOUNT_DIR, name);
     // path of datastore cannot be changed
     let (config, _) = crate::config::datastore::config()?;
     let datastores: Vec<DataStoreConfig> = config.convert_to_typed_array("datastore")?;
-- 
2.30.2






More information about the pbs-devel mailing list