mirror of
https://github.com/chatmail/core.git
synced 2026-04-29 11:26:29 +03:00
Don't scan watched folders
This should fix the duplicate-messages-bug
This commit is contained in:
@@ -30,6 +30,7 @@ impl Imap {
|
||||
let session = self.session.as_mut();
|
||||
let session = session.context("scan_folders(): IMAP No Connection established")?;
|
||||
let folders: Vec<_> = session.list(Some(""), Some("*")).await?.collect().await;
|
||||
let watched_folders = get_watched_folders(context).await;
|
||||
|
||||
let mut sentbox_folder = None;
|
||||
let mut spam_folder = None;
|
||||
@@ -42,7 +43,15 @@ impl Imap {
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
let foldername = folder.name();
|
||||
if watched_folders.contains(&foldername.to_string()) {
|
||||
info!(
|
||||
context,
|
||||
"Not scanning folder {} as it is watched anyway", foldername
|
||||
);
|
||||
continue;
|
||||
}
|
||||
info!(context, "Scanning folder: {}", foldername);
|
||||
|
||||
let folder_meaning = get_folder_meaning(&folder);
|
||||
@@ -78,3 +87,20 @@ impl Imap {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_watched_folders(context: &Context) -> Vec<String> {
|
||||
let mut res = Vec::new();
|
||||
let folder_watched_configured = &[
|
||||
(Config::SentboxWatch, Config::ConfiguredSentboxFolder),
|
||||
(Config::MvboxWatch, Config::ConfiguredMvboxFolder),
|
||||
(Config::InboxWatch, Config::ConfiguredInboxFolder),
|
||||
];
|
||||
for (watched, configured) in folder_watched_configured {
|
||||
if context.get_config_bool(*watched).await {
|
||||
if let Some(folder) = context.get_config(*configured).await {
|
||||
res.push(folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
res
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user