MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / check_storage_limit

Method check_storage_limit

nodedb/src/control/security/ceiling.rs:79–99  ·  view source on GitHub ↗

Check if adding storage would exceed the ceiling.

(
        &self,
        tenant_id: u64,
        current_bytes: u64,
        additional_bytes: u64,
    )

Source from the content-addressed store, hash-verified

77
78 /// Check if adding storage would exceed the ceiling.
79 pub fn check_storage_limit(
80 &self,
81 tenant_id: u64,
82 current_bytes: u64,
83 additional_bytes: u64,
84 ) -> crate::Result<()> {
85 let ceilings = self.ceilings.read().unwrap_or_else(|p| p.into_inner());
86 if let Some(c) = ceilings.get(&tenant_id)
87 && c.max_storage_bytes > 0
88 && current_bytes + additional_bytes > c.max_storage_bytes
89 {
90 return Err(crate::Error::RejectedAuthz {
91 tenant_id: crate::types::TenantId::new(tenant_id),
92 resource: format!(
93 "ceiling exceeded: max_storage = {} bytes",
94 c.max_storage_bytes
95 ),
96 });
97 }
98 Ok(())
99 }
100
101 /// Check if an audit entry is protected by the minimum retention ceiling.
102 /// Returns `true` if the entry CANNOT be deleted.

Callers

nothing calls this directly

Calls 2

readMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected