[pbs-devel] [PATCH proxmox-backup 2/4] datastore: introduce helper to get store's backend type
Christian Ebner
c.ebner at proxmox.com
Thu Jul 31 09:39:48 CEST 2025
In contrast to the pre-existing backend() helper, this newly
introduced backend_type() helper allows to determine a datastores
backend without already instantiating the s3 client in case the
backend is s3.
This will allow to fetch the backend type for the datastore's status
api without having to re-lookup the config.
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
pbs-datastore/src/datastore.rs | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index e8be576f7..5eb4b944b 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -234,7 +234,7 @@ impl DataStore {
/// Get the backend for this datastore based on it's configuration
pub fn backend(&self) -> Result<DatastoreBackend, Error> {
- let backend_type = match self.inner.backend_config.ty.unwrap_or_default() {
+ let backend = match self.backend_type() {
DatastoreBackendType::Filesystem => DatastoreBackend::Filesystem,
DatastoreBackendType::S3 => {
let s3_client_id = self
@@ -264,7 +264,11 @@ impl DataStore {
}
};
- Ok(backend_type)
+ Ok(backend)
+ }
+
+ pub fn backend_type(&self) -> DatastoreBackendType {
+ self.inner.backend_config.ty.unwrap_or_default()
}
pub fn cache(&self) -> Option<&LocalDatastoreLruCache> {
--
2.47.2
More information about the pbs-devel
mailing list