mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
Accept &str instead of AsRef<str> in fetch_new_mesages()
This commit is contained in:
13
src/imap.rs
13
src/imap.rs
@@ -462,7 +462,7 @@ impl Imap {
|
|||||||
self.prepare(context).await?;
|
self.prepare(context).await?;
|
||||||
|
|
||||||
while self
|
while self
|
||||||
.fetch_new_messages(context, &watch_folder, false)
|
.fetch_new_messages(context, watch_folder, false)
|
||||||
.await?
|
.await?
|
||||||
{
|
{
|
||||||
// We fetch until no more new messages are there.
|
// We fetch until no more new messages are there.
|
||||||
@@ -647,10 +647,10 @@ impl Imap {
|
|||||||
Ok(false)
|
Ok(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn fetch_new_messages<S: AsRef<str>>(
|
pub(crate) async fn fetch_new_messages(
|
||||||
&mut self,
|
&mut self,
|
||||||
context: &Context,
|
context: &Context,
|
||||||
folder: S,
|
folder: &str,
|
||||||
fetch_existing_msgs: bool,
|
fetch_existing_msgs: bool,
|
||||||
) -> Result<bool> {
|
) -> Result<bool> {
|
||||||
let show_emails = ShowEmails::from_i32(context.get_config_int(Config::ShowEmails).await?)
|
let show_emails = ShowEmails::from_i32(context.get_config_int(Config::ShowEmails).await?)
|
||||||
@@ -658,15 +658,15 @@ impl Imap {
|
|||||||
let download_limit = context.download_limit().await?;
|
let download_limit = context.download_limit().await?;
|
||||||
|
|
||||||
let new_emails = self
|
let new_emails = self
|
||||||
.select_with_uidvalidity(context, folder.as_ref())
|
.select_with_uidvalidity(context, folder)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if !new_emails && !fetch_existing_msgs {
|
if !new_emails && !fetch_existing_msgs {
|
||||||
info!(context, "No new emails in folder {}", folder.as_ref());
|
info!(context, "No new emails in folder {}", folder);
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
let old_uid_next = get_uid_next(context, folder.as_ref()).await?;
|
let old_uid_next = get_uid_next(context, folder).await?;
|
||||||
|
|
||||||
let msgs = if fetch_existing_msgs {
|
let msgs = if fetch_existing_msgs {
|
||||||
self.prefetch_existing_msgs().await?
|
self.prefetch_existing_msgs().await?
|
||||||
@@ -674,7 +674,6 @@ impl Imap {
|
|||||||
self.prefetch(old_uid_next).await?
|
self.prefetch(old_uid_next).await?
|
||||||
};
|
};
|
||||||
let read_cnt = msgs.len();
|
let read_cnt = msgs.len();
|
||||||
let folder: &str = folder.as_ref();
|
|
||||||
|
|
||||||
let mut read_errors = 0;
|
let mut read_errors = 0;
|
||||||
let mut uids_fetch_fully = Vec::with_capacity(msgs.len());
|
let mut uids_fetch_fully = Vec::with_capacity(msgs.len());
|
||||||
|
|||||||
@@ -715,7 +715,7 @@ impl Job {
|
|||||||
Config::ConfiguredSentboxFolder,
|
Config::ConfiguredSentboxFolder,
|
||||||
] {
|
] {
|
||||||
if let Some(folder) = job_try!(context.get_config(*config).await) {
|
if let Some(folder) = job_try!(context.get_config(*config).await) {
|
||||||
if let Err(e) = imap.fetch_new_messages(context, folder, true).await {
|
if let Err(e) = imap.fetch_new_messages(context, &folder, true).await {
|
||||||
// We are using Anyhow's .context() and to show the inner error, too, we need the {:#}:
|
// We are using Anyhow's .context() and to show the inner error, too, we need the {:#}:
|
||||||
warn!(context, "Could not fetch messages, retrying: {:#}", e);
|
warn!(context, "Could not fetch messages, retrying: {:#}", e);
|
||||||
return Status::RetryLater;
|
return Status::RetryLater;
|
||||||
|
|||||||
Reference in New Issue
Block a user