From ad13477754a3ddd10eb3405533244b0a0c2f7c00 Mon Sep 17 00:00:00 2001 From: link2xt Date: Wed, 16 Jul 2025 18:47:33 +0000 Subject: [PATCH 1/3] fix: bubble up QUOTA errors --- src/quota.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/quota.rs b/src/quota.rs index d6ba14f79a..3b106d3aa1 100644 --- a/src/quota.rs +++ b/src/quota.rs @@ -124,14 +124,16 @@ impl Context { /// in case for some providers the quota is always at ~100% /// and new space is allocated as needed. pub(crate) async fn update_recent_quota(&self, session: &mut ImapSession) -> Result<()> { + info!(self, "Updating IMAP quota."); + let quota = if session.can_check_quota() { let folders = get_watched_folders(self).await?; - get_unique_quota_roots_and_usage(session, folders).await + Some(get_unique_quota_roots_and_usage(session, folders).await?) } else { - Err(anyhow!(stock_str::not_supported_by_provider(self).await)) + None }; - if let Ok(quota) = "a { + let recent = if let Some(quota) = "a { match get_highest_usage(quota) { Ok((highest, _, _)) => { if needs_quota_warning( @@ -153,10 +155,13 @@ impl Context { } Err(err) => warn!(self, "cannot get highest quota usage: {:#}", err), } - } + Ok(quota) + } else { + Err(anyhow!(stock_str::not_supported_by_provider(self).await)) + }; *self.quota.write().await = Some(QuotaInfo { - recent: quota, + recent: recent.cloned(), modified: tools::Time::now(), }); From dc633404714e021dde9ee17d5f50259c38b61e35 Mon Sep 17 00:00:00 2001 From: link2xt Date: Thu, 17 Jul 2025 20:03:30 +0000 Subject: [PATCH 2/3] fix: do not ignore update_recent_quota errors --- src/context.rs | 6 +++--- src/scheduler.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/context.rs b/src/context.rs index b78a18d493..7c3b39c7c5 100644 --- a/src/context.rs +++ b/src/context.rs @@ -594,9 +594,9 @@ impl Context { .quota_needs_update(DC_BACKGROUND_FETCH_QUOTA_CHECK_RATELIMIT) .await { - if let Err(err) = self.update_recent_quota(&mut session).await { - warn!(self, "Failed to update quota: {err:#}."); - } + self.update_recent_quota(&mut session) + .await + .context("Failed to update quota")?; } } diff --git a/src/scheduler.rs b/src/scheduler.rs index 491840daff..0dfe5c8f97 100644 --- a/src/scheduler.rs +++ b/src/scheduler.rs @@ -481,9 +481,9 @@ async fn inbox_fetch_idle(ctx: &Context, imap: &mut Imap, mut session: Session) // Update quota no more than once a minute. if ctx.quota_needs_update(60).await { - if let Err(err) = ctx.update_recent_quota(&mut session).await { - warn!(ctx, "Failed to update quota: {:#}.", err); - } + ctx.update_recent_quota(&mut session) + .await + .context("Failed to update quota")?; } let resync_requested = ctx.resync_request.swap(false, Ordering::Relaxed); From 1f41177da1db98716645907181390888fbea1a3c Mon Sep 17 00:00:00 2001 From: link2xt Date: Thu, 17 Jul 2025 20:04:21 +0000 Subject: [PATCH 3/3] fix: do not ignore resync_folders --- src/scheduler.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/scheduler.rs b/src/scheduler.rs index 0dfe5c8f97..18ea1dd78c 100644 --- a/src/scheduler.rs +++ b/src/scheduler.rs @@ -488,10 +488,10 @@ async fn inbox_fetch_idle(ctx: &Context, imap: &mut Imap, mut session: Session) let resync_requested = ctx.resync_request.swap(false, Ordering::Relaxed); if resync_requested { - if let Err(err) = session.resync_folders(ctx).await { - warn!(ctx, "Failed to resync folders: {:#}.", err); - ctx.resync_request.store(true, Ordering::Relaxed); - } + session + .resync_folders(ctx) + .await + .context("resync_folders")?; } maybe_add_time_based_warnings(ctx).await;