1 parent
96a32ea8fb
commit
a643e7e3ab
106 files changed
+2223
-4669
No files matched your search
+2
-11
@@ -13,17 +13,11 @@ use crate::imap::client::{ImapClient, ImapCredentials};
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct QuotaResponse {
|
||||
/// Storage used in bytes, or null if unavailable.
|
||||
usage_bytes: Option<u64>,
|
||||
/// Storage limit in bytes, or null if unlimited/unavailable.
|
||||
|
||||
limit_bytes: Option<u64>,
|
||||
}
|
||||
|
||||
/// `GET /api/quota`
|
||||
///
|
||||
/// Returns the mailbox storage quota for the authenticated user.
|
||||
/// Tries IMAP GETQUOTAROOT first; if no quota is configured, falls back to
|
||||
/// the cached message sizes (an estimate during sync). An empty cache uses IMAP.
|
||||
pub async fn get_quota(
|
||||
Extension(session): Extension<SessionState>,
|
||||
Extension(config): Extension<Arc<AppConfig>>,
|
||||
@@ -38,7 +32,6 @@ pub async fn get_quota(
|
||||
password: session.password.clone(),
|
||||
};
|
||||
|
||||
// Try IMAP GETQUOTAROOT first.
|
||||
let quota = imap_client.get_quota(&creds).await.unwrap_or(None);
|
||||
|
||||
let resp = match quota {
|
||||
@@ -63,8 +56,7 @@ pub async fn get_quota(
|
||||
})
|
||||
.into_response());
|
||||
}
|
||||
// Empty cache: sum RFC822.SIZE across all folders.
|
||||
// Run SQLite access in spawn_blocking to avoid blocking the executor.
|
||||
|
||||
let data_dir = config.data_dir.clone();
|
||||
let user_hash = session.user_hash.clone();
|
||||
let folders: Vec<String> = tokio::task::spawn_blocking(move || {
|
||||
@@ -81,7 +73,6 @@ pub async fn get_quota(
|
||||
.map_err(|e| AppError::InternalError(format!("Task error: {e}")))?
|
||||
.map_err(|e| AppError::InternalError(format!("Database error: {e}")))?;
|
||||
|
||||
// Fetch sizes with a 90s overall timeout.
|
||||
let total = tokio::time::timeout(
|
||||
Duration::from_secs(90),
|
||||
crate::imap::pool::background(async {
|
||||
|
||||
Reference in new issue
Block a user