From 42103c467db5f49a0e7e7eb224a22316024ce7ad Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Thu, 5 May 2022 17:15:31 +0200 Subject: [PATCH] ns: max depth: set constant to upper inclusive boundary makes usage a bit simpler, e.g., the api maximum can use that 1:1 then. Signed-off-by: Thomas Lamprecht --- pbs-api-types/src/datastore.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs index 8eb2ad62..8c7ebad0 100644 --- a/pbs-api-types/src/datastore.rs +++ b/pbs-api-types/src/datastore.rs @@ -69,7 +69,10 @@ pub const BACKUP_GROUP_SCHEMA: Schema = StringSchema::new("Backup Group") .format(&BACKUP_GROUP_FORMAT) .schema(); -pub const MAX_NAMESPACE_DEPTH: usize = 8; +/// The maximal, inclusive depth for namespaces from the root ns downwards +/// +/// The datastore root name space is at depth zero (0), so we have in total eight (8) levels +pub const MAX_NAMESPACE_DEPTH: usize = 7; pub const MAX_BACKUP_NAMESPACE_LENGTH: usize = 32 * 8; // 256 pub const BACKUP_NAMESPACE_SCHEMA: Schema = StringSchema::new("Namespace.") .format(&BACKUP_NAMESPACE_FORMAT) @@ -611,7 +614,7 @@ impl BackupNamespace { /// Assumes `subdir` already does not contain any slashes. /// Performs remaining checks and updates the length. fn push_do(&mut self, subdir: String) -> Result<(), Error> { - if self.depth() >= MAX_NAMESPACE_DEPTH { + if self.depth() > MAX_NAMESPACE_DEPTH { bail!( "namespace to deep, {} > max {}", self.inner.len(),