Skip to content

Commit 1e94e06

Browse files
committed
feat: Remove Config::SentboxWatch (#7178)
The motivation is to reduce code complexity, get rid of the extra IMAP connection and cases when messages are added to chats by Inbox and Sentbox loops in parallel which leads to various message sorting bugs, particularly to outgoing messages breaking sorting of incoming ones which are fetched later, but may have a smaller "Date".
1 parent ab8aedf commit 1e94e06

File tree

10 files changed

+30
-75
lines changed

10 files changed

+30
-75
lines changed

python/src/deltachat/testplugin.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,6 @@ def prepare_account_from_liveconfig(self, configdict) -> Account:
523523
assert "addr" in configdict and "mail_pw" in configdict, configdict
524524
configdict.setdefault("bcc_self", False)
525525
configdict.setdefault("mvbox_move", False)
526-
configdict.setdefault("sentbox_watch", False)
527526
configdict.setdefault("sync_msgs", False)
528527
configdict.setdefault("delete_server_after", 0)
529528
ac.update_config(configdict)

python/tests/test_1_online.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,19 +269,21 @@ def test_enable_mvbox_move(acfactory, lp):
269269
assert ac2._evtracker.wait_next_incoming_message().text == "message1"
270270

271271

272-
def test_mvbox_sentbox_threads(acfactory, lp):
272+
def test_mvbox_thread_and_sentbox(acfactory, lp):
273273
lp.sec("ac1: start with mvbox thread")
274-
ac1 = acfactory.new_online_configuring_account(mvbox_move=True, sentbox_watch=False)
274+
ac1 = acfactory.new_online_configuring_account(mvbox_move=True)
275275

276-
lp.sec("ac2: start without mvbox/sentbox threads")
277-
ac2 = acfactory.new_online_configuring_account(mvbox_move=False, sentbox_watch=False)
276+
lp.sec("ac2: start without a mvbox thread")
277+
ac2 = acfactory.new_online_configuring_account(mvbox_move=False)
278278

279279
lp.sec("ac2 and ac1: waiting for configuration")
280280
acfactory.bring_accounts_online()
281281

282-
lp.sec("ac1: create and configure sentbox")
282+
lp.sec("ac1: create sentbox")
283283
ac1.direct_imap.create_folder("Sent")
284-
ac1.set_config("sentbox_watch", "1")
284+
ac1.set_config("scan_all_folders_debounce_secs", "0")
285+
ac1.stop_io()
286+
ac1.start_io()
285287

286288
lp.sec("ac1: send message and wait for ac2 to receive it")
287289
acfactory.get_accepted_chat(ac1, ac2).send_text("message1")

scripts/update-provider-database.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -euo pipefail
66
export TZ=UTC
77

88
# Provider database revision.
9-
REV=1cce91c1f1065b47e4f307d6fe2f4cca68c74d2e
9+
REV=d041136c19a48b493823b46d472f12b9ee94ae80
1010

1111
CORE_ROOT="$PWD"
1212
TMP="$(mktemp -d)"

src/config.rs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,6 @@ pub enum Config {
156156
#[strum(props(default = "1"))]
157157
MdnsEnabled,
158158

159-
/// True if "Sent" folder should be watched for changes.
160-
#[strum(props(default = "0"))]
161-
SentboxWatch,
162-
163159
/// True if chat messages should be moved to a separate folder. Auto-sent messages like sync
164160
/// ones are moved there anyway.
165161
#[strum(props(default = "1"))]
@@ -476,10 +472,7 @@ impl Config {
476472

477473
/// Whether the config option needs an IO scheduler restart to take effect.
478474
pub(crate) fn needs_io_restart(&self) -> bool {
479-
matches!(
480-
self,
481-
Config::MvboxMove | Config::OnlyFetchMvbox | Config::SentboxWatch
482-
)
475+
matches!(self, Config::MvboxMove | Config::OnlyFetchMvbox)
483476
}
484477
}
485478

@@ -605,15 +598,6 @@ impl Context {
605598
|| !self.get_config_bool(Config::IsChatmail).await?)
606599
}
607600

608-
/// Returns true if sentbox ("Sent" folder) should be watched.
609-
pub(crate) async fn should_watch_sentbox(&self) -> Result<bool> {
610-
Ok(self.get_config_bool(Config::SentboxWatch).await?
611-
&& self
612-
.get_config(Config::ConfiguredSentboxFolder)
613-
.await?
614-
.is_some())
615-
}
616-
617601
/// Returns true if sync messages should be sent.
618602
pub(crate) async fn should_send_sync_msgs(&self) -> Result<bool> {
619603
Ok(self.get_config_bool(Config::SyncMsgs).await?
@@ -702,7 +686,6 @@ impl Context {
702686
| Config::ProxyEnabled
703687
| Config::BccSelf
704688
| Config::MdnsEnabled
705-
| Config::SentboxWatch
706689
| Config::MvboxMove
707690
| Config::OnlyFetchMvbox
708691
| Config::DeleteToTrash
@@ -732,11 +715,7 @@ impl Context {
732715
true => self.scheduler.pause(self).await?,
733716
_ => Default::default(),
734717
};
735-
self.set_config_internal(key, value).await?;
736-
if key == Config::SentboxWatch {
737-
self.last_full_folder_scan.lock().await.take();
738-
}
739-
Ok(())
718+
self.set_config_internal(key, value).await
740719
}
741720

742721
pub(crate) async fn set_config_internal(&self, key: Config, value: Option<&str>) -> Result<()> {

src/configure.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,6 @@ async fn configure(ctx: &Context, param: &EnteredLoginParam) -> Result<Option<&'
555555
true => ctx.get_config_bool(Config::IsChatmail).await?,
556556
};
557557
if is_chatmail {
558-
ctx.set_config(Config::SentboxWatch, None).await?;
559558
ctx.set_config(Config::MvboxMove, Some("0")).await?;
560559
ctx.set_config(Config::OnlyFetchMvbox, None).await?;
561560
ctx.set_config(Config::ShowEmails, None).await?;

src/context.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,6 @@ impl Context {
849849
Err(err) => format!("<key failure: {err}>"),
850850
};
851851

852-
let sentbox_watch = self.get_config_int(Config::SentboxWatch).await?;
853852
let mvbox_move = self.get_config_int(Config::MvboxMove).await?;
854853
let only_fetch_mvbox = self.get_config_int(Config::OnlyFetchMvbox).await?;
855854
let folders_configured = self
@@ -954,7 +953,6 @@ impl Context {
954953
.await?
955954
.to_string(),
956955
);
957-
res.insert("sentbox_watch", sentbox_watch.to_string());
958956
res.insert("mvbox_move", mvbox_move.to_string());
959957
res.insert("only_fetch_mvbox", only_fetch_mvbox.to_string());
960958
res.insert(

src/imap.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2524,10 +2524,6 @@ async fn should_ignore_folder(
25242524
if !context.get_config_bool(Config::OnlyFetchMvbox).await? {
25252525
return Ok(false);
25262526
}
2527-
if context.is_sentbox(folder).await? {
2528-
// Still respect the SentboxWatch setting.
2529-
return Ok(!context.get_config_bool(Config::SentboxWatch).await?);
2530-
}
25312527
Ok(!(context.is_mvbox(folder).await? || folder_meaning == FolderMeaning::Spam))
25322528
}
25332529

src/imap/scan_folders.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@ impl Imap {
108108

109109
pub(crate) async fn get_watched_folder_configs(context: &Context) -> Result<Vec<Config>> {
110110
let mut res = vec![Config::ConfiguredInboxFolder];
111-
if context.get_config_bool(Config::SentboxWatch).await? {
112-
res.push(Config::ConfiguredSentboxFolder);
113-
}
114111
if context.should_watch_mvbox().await? {
115112
res.push(Config::ConfiguredMvboxFolder);
116113
}

src/provider/data.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -510,10 +510,6 @@ static P_FIVE_CHAT: Provider = Provider {
510510
key: Config::BccSelf,
511511
value: "1",
512512
},
513-
ConfigDefault {
514-
key: Config::SentboxWatch,
515-
value: "0",
516-
},
517513
ConfigDefault {
518514
key: Config::MvboxMove,
519515
value: "0",
@@ -1084,10 +1080,6 @@ static P_NAUTA_CU: Provider = Provider {
10841080
key: Config::DeleteServerAfter,
10851081
value: "1",
10861082
},
1087-
ConfigDefault {
1088-
key: Config::SentboxWatch,
1089-
value: "0",
1090-
},
10911083
ConfigDefault {
10921084
key: Config::MvboxMove,
10931085
value: "0",
@@ -1629,10 +1621,6 @@ static P_TESTRUN: Provider = Provider {
16291621
key: Config::BccSelf,
16301622
value: "1",
16311623
},
1632-
ConfigDefault {
1633-
key: Config::SentboxWatch,
1634-
value: "0",
1635-
},
16361624
ConfigDefault {
16371625
key: Config::MvboxMove,
16381626
value: "0",
@@ -1898,11 +1886,11 @@ static P_WKPB_DE: Provider = Provider {
18981886
oauth2_authorizer: None,
18991887
};
19001888

1901-
// yahoo.md: yahoo.com, yahoo.de, yahoo.it, yahoo.fr, yahoo.es, yahoo.se, yahoo.co.uk, yahoo.co.nz, yahoo.com.au, yahoo.com.ar, yahoo.com.br, yahoo.com.mx, ymail.com, rocketmail.com, yahoodns.net
1889+
// yahoo.md: yahoo.com, yahoo.de, yahoo.it, yahoo.fr, yahoo.es, yahoo.se, yahoo.co.uk, yahoo.co.nz, yahoo.com.au, yahoo.com.ar, yahoo.com.br, yahoo.com.mx, myyahoo.com, ymail.com, rocketmail.com, yahoodns.net
19021890
static P_YAHOO: Provider = Provider {
19031891
id: "yahoo",
19041892
status: Status::Preparation,
1905-
before_login_hint: "To use your Yahoo email address you have to create an \"App-Password\" in the account security screen.",
1893+
before_login_hint: "To use your Yahoo email address you have to create an app password in the Yahoo account security screen.",
19061894
after_login_hint: "",
19071895
overview_page: "https://providers.delta.chat/yahoo",
19081896
server: &[
@@ -2041,7 +2029,7 @@ static P_ZOHO: Provider = Provider {
20412029
oauth2_authorizer: None,
20422030
};
20432031

2044-
pub(crate) static PROVIDER_DATA: [(&str, &Provider); 533] = [
2032+
pub(crate) static PROVIDER_DATA: [(&str, &Provider); 534] = [
20452033
("163.com", &P_163),
20462034
("aktivix.org", &P_AKTIVIX_ORG),
20472035
("aliyun.com", &P_ALIYUN),
@@ -2560,6 +2548,7 @@ pub(crate) static PROVIDER_DATA: [(&str, &Provider); 533] = [
25602548
("yahoo.com.ar", &P_YAHOO),
25612549
("yahoo.com.br", &P_YAHOO),
25622550
("yahoo.com.mx", &P_YAHOO),
2551+
("myyahoo.com", &P_YAHOO),
25632552
("ymail.com", &P_YAHOO),
25642553
("rocketmail.com", &P_YAHOO),
25652554
("yahoodns.net", &P_YAHOO),
@@ -2658,4 +2647,4 @@ pub(crate) static PROVIDER_IDS: LazyLock<HashMap<&'static str, &'static Provider
26582647
});
26592648

26602649
pub static _PROVIDER_UPDATED: LazyLock<chrono::NaiveDate> =
2661-
LazyLock::new(|| chrono::NaiveDate::from_ymd_opt(2025, 9, 4).unwrap());
2650+
LazyLock::new(|| chrono::NaiveDate::from_ymd_opt(2025, 9, 10).unwrap());

src/scheduler.rs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ impl SchedulerState {
254254
}
255255
}
256256

257-
/// Interrupt optional boxes (mvbox, sentbox) loops.
257+
/// Interrupt optional boxes (mvbox currently) loops.
258258
pub(crate) async fn interrupt_oboxes(&self) {
259259
let inner = self.inner.read().await;
260260
if let InnerSchedulerState::Started(ref scheduler) = *inner {
@@ -333,7 +333,7 @@ struct SchedBox {
333333
#[derive(Debug)]
334334
pub(crate) struct Scheduler {
335335
inbox: SchedBox,
336-
/// Optional boxes -- mvbox, sentbox.
336+
/// Optional boxes -- mvbox.
337337
oboxes: Vec<SchedBox>,
338338
smtp: SmtpConnectionState,
339339
smtp_handle: task::JoinHandle<()>,
@@ -878,22 +878,18 @@ impl Scheduler {
878878
};
879879
start_recvs.push(inbox_start_recv);
880880

881-
for (meaning, should_watch) in [
882-
(FolderMeaning::Mvbox, ctx.should_watch_mvbox().await),
883-
(FolderMeaning::Sent, ctx.should_watch_sentbox().await),
884-
] {
885-
if should_watch? {
886-
let (conn_state, handlers) = ImapConnectionState::new(ctx).await?;
887-
let (start_send, start_recv) = oneshot::channel();
888-
let ctx = ctx.clone();
889-
let handle = task::spawn(simple_imap_loop(ctx, start_send, handlers, meaning));
890-
oboxes.push(SchedBox {
891-
meaning,
892-
conn_state,
893-
handle,
894-
});
895-
start_recvs.push(start_recv);
896-
}
881+
if ctx.should_watch_mvbox().await? {
882+
let (conn_state, handlers) = ImapConnectionState::new(ctx).await?;
883+
let (start_send, start_recv) = oneshot::channel();
884+
let ctx = ctx.clone();
885+
let meaning = FolderMeaning::Mvbox;
886+
let handle = task::spawn(simple_imap_loop(ctx, start_send, handlers, meaning));
887+
oboxes.push(SchedBox {
888+
meaning,
889+
conn_state,
890+
handle,
891+
});
892+
start_recvs.push(start_recv);
897893
}
898894

899895
let smtp_handle = {

0 commit comments

Comments
 (0)