Fix quota: Include Sieve scripts in quota recalculations
This commit is contained in:
@@ -22,6 +22,7 @@ If you are upgrading from v0.16.x, replace the binary (or run `docker pull`). If
|
|||||||
- Import tool fails to restore registry entries.
|
- Import tool fails to restore registry entries.
|
||||||
- FDB: Allow multiple FoundationDB instances in the same process.
|
- FDB: Allow multiple FoundationDB instances in the same process.
|
||||||
- Autoconfig: Return `%EMAILADDRESS%` when no email address is provided.
|
- Autoconfig: Return `%EMAILADDRESS%` when no email address is provided.
|
||||||
|
- Quota: Include Sieve scripts in quota recalculations.
|
||||||
|
|
||||||
## [0.16.3] - 2026-04-30
|
## [0.16.3] - 2026-04-30
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ impl Server {
|
|||||||
item_size: u64,
|
item_size: u64,
|
||||||
) -> trc::Result<()> {
|
) -> trc::Result<()> {
|
||||||
if account.quota_disk != 0 {
|
if account.quota_disk != 0 {
|
||||||
let used_quota = self.get_used_quota_account(account.id).await? as u64;
|
let used_quota = self.get_used_quota_account(account.id).await?.max(0) as u64;
|
||||||
|
|
||||||
if used_quota + item_size > account.quota_disk {
|
if used_quota + item_size > account.quota_disk {
|
||||||
return Err(trc::LimitEvent::Quota
|
return Err(trc::LimitEvent::Quota
|
||||||
@@ -76,7 +76,7 @@ impl Server {
|
|||||||
let tenant = self.tenant(tenant_id).await.caused_by(trc::location!())?;
|
let tenant = self.tenant(tenant_id).await.caused_by(trc::location!())?;
|
||||||
|
|
||||||
if tenant.quota_disk != 0 {
|
if tenant.quota_disk != 0 {
|
||||||
let used_quota = self.get_used_quota_tenant(tenant_id).await? as u64;
|
let used_quota = self.get_used_quota_tenant(tenant_id).await?.max(0) as u64;
|
||||||
|
|
||||||
if used_quota + item_size > tenant.quota_disk {
|
if used_quota + item_size > tenant.quota_disk {
|
||||||
return Err(trc::LimitEvent::TenantQuota
|
return Err(trc::LimitEvent::TenantQuota
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ impl QuotaGet for Server {
|
|||||||
QuotaProperty::Id => Value::Element(id.into()),
|
QuotaProperty::Id => Value::Element(id.into()),
|
||||||
QuotaProperty::ResourceType => "octets".to_string().into(),
|
QuotaProperty::ResourceType => "octets".to_string().into(),
|
||||||
QuotaProperty::Used => {
|
QuotaProperty::Used => {
|
||||||
(self.get_used_quota_account(account_id).await? as u64).into()
|
(self.get_used_quota_account(account_id).await?.max(0) as u64).into()
|
||||||
}
|
}
|
||||||
QuotaProperty::HardLimit => account.as_ref().disk_quota().into(),
|
QuotaProperty::HardLimit => account.as_ref().disk_quota().into(),
|
||||||
QuotaProperty::Scope => "account".to_string().into(),
|
QuotaProperty::Scope => "account".to_string().into(),
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ use common::{
|
|||||||
use email::{
|
use email::{
|
||||||
cache::MessageCacheFetch,
|
cache::MessageCacheFetch,
|
||||||
message::{delete::EmailDeletion, ingest::EmailIngest, metadata::MessageData},
|
message::{delete::EmailDeletion, ingest::EmailIngest, metadata::MessageData},
|
||||||
|
sieve::SieveScript,
|
||||||
};
|
};
|
||||||
use groupware::{
|
use groupware::{
|
||||||
calendar::{Calendar, CalendarEvent, CalendarEventNotification},
|
calendar::{Calendar, CalendarEvent, CalendarEventNotification},
|
||||||
@@ -450,6 +451,7 @@ async fn recalculate_quota(server: &Server, account_id: u32) -> trc::Result<()>
|
|||||||
Collection::AddressBook,
|
Collection::AddressBook,
|
||||||
Collection::ContactCard,
|
Collection::ContactCard,
|
||||||
Collection::FileNode,
|
Collection::FileNode,
|
||||||
|
Collection::SieveScript,
|
||||||
] {
|
] {
|
||||||
server
|
server
|
||||||
.archives(account_id, collection, &(), |_, archive| {
|
.archives(account_id, collection, &(), |_, archive| {
|
||||||
@@ -475,6 +477,9 @@ async fn recalculate_quota(server: &Server, account_id: u32) -> trc::Result<()>
|
|||||||
Collection::FileNode => {
|
Collection::FileNode => {
|
||||||
quota += archive.unarchive::<FileNode>()?.size() as i64;
|
quota += archive.unarchive::<FileNode>()?.size() as i64;
|
||||||
}
|
}
|
||||||
|
Collection::SieveScript => {
|
||||||
|
quota += u32::from(archive.unarchive::<SieveScript>()?.size) as i64;
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(true)
|
Ok(true)
|
||||||
|
|||||||
Reference in New Issue
Block a user