Skip to content

Commit 0c17f7f

Browse files
committed
fix: bubble up QUOTA errors
1 parent 8fc6ea1 commit 0c17f7f

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/quota.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,16 @@ impl Context {
124124
/// in case for some providers the quota is always at ~100%
125125
/// and new space is allocated as needed.
126126
pub(crate) async fn update_recent_quota(&self, session: &mut ImapSession) -> Result<()> {
127+
info!(self, "Updating IMAP quota.");
128+
127129
let quota = if session.can_check_quota() {
128130
let folders = get_watched_folders(self).await?;
129-
get_unique_quota_roots_and_usage(session, folders).await
131+
Some(get_unique_quota_roots_and_usage(session, folders).await?)
130132
} else {
131-
Err(anyhow!(stock_str::not_supported_by_provider(self).await))
133+
None
132134
};
133135

134-
if let Ok(quota) = &quota {
136+
let recent = if let Some(quota) = &quota {
135137
match get_highest_usage(quota) {
136138
Ok((highest, _, _)) => {
137139
if needs_quota_warning(
@@ -153,10 +155,13 @@ impl Context {
153155
}
154156
Err(err) => warn!(self, "cannot get highest quota usage: {:#}", err),
155157
}
156-
}
158+
Ok(quota)
159+
} else {
160+
Err(anyhow!(stock_str::not_supported_by_provider(self).await))
161+
};
157162

158163
*self.quota.write().await = Some(QuotaInfo {
159-
recent: quota,
164+
recent: recent.cloned(),
160165
modified: tools::Time::now(),
161166
});
162167

0 commit comments

Comments
 (0)