diff --git a/src/autorelay.rs b/src/autorelay.rs index d93233449..204995394 100644 --- a/src/autorelay.rs +++ b/src/autorelay.rs @@ -14,7 +14,7 @@ use rusqlite::Transaction; use tokio::task::JoinSet; use crate::config::{self, Config}; -use crate::configure::{EnteredLoginParam, configure}; +use crate::configure::{EnteredLoginParam, SILENT_PROGRESS, configure}; use crate::log::{LogExt, warn}; use crate::login_param::{EnteredCertificateChecks, EnteredImapLoginParam}; use crate::net::{connect_tcp, proxy::ProxyConfig}; @@ -190,7 +190,9 @@ async fn maybe_add_additional_relays_inner(context: &Context, skip_network: bool .await?; let mark_as_autorelay = true; let param = login_param_from_host(host, mark_as_autorelay); - let res = configure(context, ¶m, skip_network).await; + let res = SILENT_PROGRESS + .scope((), configure(context, ¶m, skip_network)) + .await; if let Err(e) = res { warn!( context, diff --git a/src/autorelay/autorelay_tests.rs b/src/autorelay/autorelay_tests.rs index 2e08de1ff..9512bf52d 100644 --- a/src/autorelay/autorelay_tests.rs +++ b/src/autorelay/autorelay_tests.rs @@ -1,6 +1,7 @@ use std::time::Duration; use super::*; +use crate::EventType; use crate::test_utils::{TestContext, TestContextManager}; use crate::tools::SystemTime; @@ -44,6 +45,7 @@ async fn test_add_transport_from_candidates() -> Result<()> { assert!(transports[0].addr.ends_with("@example.org")); let untried = untried_relay_candidates(t).await?; assert_eq!(untried, ["example.org"]); + assert!(configure_progress_emitted(t).await); Ok(()) } @@ -99,6 +101,14 @@ async fn mark_defaults_tried(t: &TestContext, now: i64) -> Result<()> { save_relay_candidates(t, DEFAULT_RELAY_CANDIDATES, now).await } +/// Consumes emitted events, telling whether a configure progress is among them. +async fn configure_progress_emitted(t: &TestContext) -> bool { + t.evtracker + .get_matching_opt(t, |evt| matches!(evt, EventType::ConfigureProgress { .. })) + .await + .is_some() +} + /// Tests that saving a candidate overwrites its stored timestamp. #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_save_relay_candidate() -> Result<()> { @@ -265,6 +275,7 @@ async fn test_maybe_add_additional_relays_add_one() -> Result<()> { let transports_after = t.count_transports().await?; assert_eq!(transports_after, transports_before + 1); + assert!(!configure_progress_emitted(t).await); Ok(()) } diff --git a/src/configure.rs b/src/configure.rs index d77d83dc7..eaa67d9e2 100644 --- a/src/configure.rs +++ b/src/configure.rs @@ -47,12 +47,19 @@ use crate::{EventType, autorelay, stock_str}; /// See . pub(crate) const MAX_RELAYS: usize = 5; +tokio::task_local! { + pub(crate) static SILENT_PROGRESS: (); +} + #[track_caller] fn emit_progress(ctx: &Context, progress: u16) { assert!( progress <= 1000, "value in range 0..1000 expected with: 0=error, 1..999=progress, 1000=success" ); + if SILENT_PROGRESS.try_with(|_| ()).is_ok() { + return; + } ctx.emit_event(EventType::ConfigureProgress { progress, comment: None,