diff --git a/markbase-core/src/webdav.rs b/markbase-core/src/webdav.rs index d12f340..52429e8 100644 --- a/markbase-core/src/webdav.rs +++ b/markbase-core/src/webdav.rs @@ -510,6 +510,30 @@ impl DavFile for VfsDavFile { return Box::pin(std::future::ready(Ok(()))); } + // Quota check before write + if !self.data.is_empty() { + if let Some(vfs) = &self.vfs { + if let Some(path) = &self.path { + let usage = vfs.get_quota_usage(path); + let quota = vfs.get_quota(path); + if let (Ok(usage), Ok(quota)) = (usage, quota) { + if quota.space_limit > 0 { + let new_size = usage.space_used + self.data.len() as u64; + if new_size > quota.space_limit { + log::warn!( + "Quota exceeded: current={}, adding={}, limit={}", + usage.space_used, + self.data.len(), + quota.space_limit + ); + return Box::pin(std::future::ready(Err(FsError::InsufficientStorage))); + } + } + } + } + } + } + // Phase 1: Flush to storage if let Some(vfs_file_mutex) = &self.vfs_file { match vfs_file_mutex.lock() {