use constant for folders_configured cache

This commit is contained in:
B. Petersen
2020-03-24 19:18:18 +01:00
parent 4fabddeb47
commit f28f177c6b
2 changed files with 9 additions and 6 deletions

View File

@@ -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,

View File

@@ -1074,9 +1074,7 @@ 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(());
} }
@@ -1168,9 +1166,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(())