From 8c95336c890ee5d33dc768b4abdfc123163380c7 Mon Sep 17 00:00:00 2001 From: iequidoo Date: Tue, 30 Sep 2025 14:45:13 -0300 Subject: [PATCH] feat: Enable OnlyFetchMvbox by default (#7190) This is a replacement for 2260156c40ebbb4b29cf5809f7fa8368ff57052b "feat: Don't fetch messages from unknown folders", but limited to the case with `MvboxMove` enabled. It's enabled by default, so most users still gain from not fetching messages from unknown folders. --- src/config.rs | 2 +- src/imap/imap_tests.rs | 3 ++- src/sql/migrations.rs | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/config.rs b/src/config.rs index c26e130b3..fa917c7c7 100644 --- a/src/config.rs +++ b/src/config.rs @@ -169,7 +169,7 @@ pub enum Config { /// /// This will not entirely disable other folders, e.g. the spam folder will also still /// be scanned for new messages. - #[strum(props(default = "0"))] + #[strum(props(default = "1"))] OnlyFetchMvbox, /// Whether to show classic emails or only chat messages. diff --git a/src/imap/imap_tests.rs b/src/imap/imap_tests.rs index 1aa746ea9..34c7bb9df 100644 --- a/src/imap/imap_tests.rs +++ b/src/imap/imap_tests.rs @@ -122,8 +122,9 @@ async fn check_target_folder_combination( t.ctx .set_config(Config::ConfiguredSentboxFolder, Some("Sent")) .await?; + t.ctx.set_config_bool(Config::MvboxMove, mvbox_move).await?; t.ctx - .set_config(Config::MvboxMove, Some(if mvbox_move { "1" } else { "0" })) + .set_config_bool(Config::OnlyFetchMvbox, mvbox_move) .await?; if accepted_chat { diff --git a/src/sql/migrations.rs b/src/sql/migrations.rs index 116a2a0ef..7a6bf775d 100644 --- a/src/sql/migrations.rs +++ b/src/sql/migrations.rs @@ -1342,6 +1342,20 @@ CREATE INDEX gossip_timestamp_index ON gossip_timestamp (chat_id, fingerprint); .await?; } + inc_and_check(&mut migration_version, 139)?; + if dbversion < migration_version { + // `OnlyFetchMvbox` is now 1 by default to avoid scanning unknown folders. But if the user + // disabled `MvboxMove`, we have to keep `OnlyFetchMvbox` unset so that Inbox is watched. + sql.execute_migration( + "INSERT OR IGNORE INTO config (keyname, value) + SELECT 'only_fetch_mvbox', '0' + FROM config WHERE keyname='mvbox_move' AND value='0' + ", + migration_version, + ) + .await?; + } + let new_version = sql .get_raw_config_int(VERSION_CFG) .await?