mirror of
https://github.com/chatmail/core.git
synced 2026-05-09 01:46:30 +03:00
Merge pull request #1359 from deltachat/fix-imap-delimiter
fix imap delimiter
This commit is contained in:
@@ -371,7 +371,7 @@ pub(crate) fn JobConfigureImap(context: &Context) -> job::Status {
|
|||||||
let create_mvbox = context.get_config_bool(Config::MvboxWatch)
|
let create_mvbox = context.get_config_bool(Config::MvboxWatch)
|
||||||
|| context.get_config_bool(Config::MvboxMove);
|
|| context.get_config_bool(Config::MvboxMove);
|
||||||
let imap = &context.inbox_thread.read().unwrap().imap;
|
let imap = &context.inbox_thread.read().unwrap().imap;
|
||||||
if let Err(err) = imap.ensure_configured_folders(context, create_mvbox) {
|
if let Err(err) = imap.configure_folders(context, create_mvbox) {
|
||||||
warn!(context, "configuring folders failed: {:?}", err);
|
warn!(context, "configuring folders failed: {:?}", err);
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -214,6 +214,9 @@ pub const DC_BOB_SUCCESS: i32 = 1;
|
|||||||
// max. width/height of an avatar
|
// max. width/height of an avatar
|
||||||
pub const AVATAR_SIZE: u32 = 192;
|
pub const AVATAR_SIZE: u32 = 192;
|
||||||
|
|
||||||
|
// this value can be increased if the folder configuration is changed and must be redone on next program start
|
||||||
|
pub const DC_FOLDERS_CONFIGURED_VERSION: i32 = 3;
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug,
|
Debug,
|
||||||
Display,
|
Display,
|
||||||
|
|||||||
@@ -188,7 +188,6 @@ struct ImapConfig {
|
|||||||
/// True if the server has MOVE capability as defined in
|
/// True if the server has MOVE capability as defined in
|
||||||
/// https://tools.ietf.org/html/rfc6851
|
/// https://tools.ietf.org/html/rfc6851
|
||||||
pub can_move: bool,
|
pub can_move: bool,
|
||||||
pub imap_delimiter: char,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ImapConfig {
|
impl Default for ImapConfig {
|
||||||
@@ -206,7 +205,6 @@ impl Default for ImapConfig {
|
|||||||
selected_folder_needs_expunge: false,
|
selected_folder_needs_expunge: false,
|
||||||
can_idle: false,
|
can_idle: false,
|
||||||
can_move: false,
|
can_move: false,
|
||||||
imap_delimiter: '.',
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1074,12 +1072,14 @@ impl Imap {
|
|||||||
let folders_configured = context
|
let folders_configured = context
|
||||||
.sql
|
.sql
|
||||||
.get_raw_config_int(context, "folders_configured");
|
.get_raw_config_int(context, "folders_configured");
|
||||||
if folders_configured.unwrap_or_default() >= 3 {
|
if folders_configured.unwrap_or_default() >= DC_FOLDERS_CONFIGURED_VERSION {
|
||||||
// the "3" here we increase if we have future updates to
|
|
||||||
// to folder configuration
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.configure_folders(context, create_mvbox)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn configure_folders(&self, context: &Context, create_mvbox: bool) -> Result<()> {
|
||||||
task::block_on(async move {
|
task::block_on(async move {
|
||||||
if !self.is_connected().await {
|
if !self.is_connected().await {
|
||||||
return Err(Error::NoConnection);
|
return Err(Error::NoConnection);
|
||||||
@@ -1104,7 +1104,15 @@ impl Imap {
|
|||||||
});
|
});
|
||||||
info!(context, "sentbox folder is {:?}", sentbox_folder);
|
info!(context, "sentbox folder is {:?}", sentbox_folder);
|
||||||
|
|
||||||
let delimiter = self.config.read().await.imap_delimiter;
|
let mut delimiter = ".";
|
||||||
|
if let Some(folder) = folders.first() {
|
||||||
|
if let Some(d) = folder.delimiter() {
|
||||||
|
if !d.is_empty() {
|
||||||
|
delimiter = d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
info!(context, "Using \"{}\" as folder-delimiter.", delimiter);
|
||||||
let fallback_folder = format!("INBOX{}DeltaChat", delimiter);
|
let fallback_folder = format!("INBOX{}DeltaChat", delimiter);
|
||||||
|
|
||||||
let mut mvbox_folder = folders
|
let mut mvbox_folder = folders
|
||||||
@@ -1168,9 +1176,11 @@ impl Imap {
|
|||||||
Some(sentbox_folder.name()),
|
Some(sentbox_folder.name()),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
context
|
context.sql.set_raw_config_int(
|
||||||
.sql
|
context,
|
||||||
.set_raw_config_int(context, "folders_configured", 3)?;
|
"folders_configured",
|
||||||
|
DC_FOLDERS_CONFIGURED_VERSION,
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
info!(context, "FINISHED configuring IMAP-folders.");
|
info!(context, "FINISHED configuring IMAP-folders.");
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user