commit 6f8eb2710134cde1501dfca708fda3d16d9ab578 from: Thomas Böhler date: Thu Oct 23 17:34:04 2025 UTC fix: drain mpsc when running with --dry-run The --dry-run option should fetch all feeds, store them in the database, mark them as sent, but not actually send any emails. The previous implementation only fetched all feeds and fed them to the mpsc that is shared by the accumulator and the sender, but as the sender wasn't running, nothing received the feed items from the channel, which made the accumulator block, as the channel only fits 10 items. Move the dry run logic as deep into the sender as possible so all the logic still runs and just the emails aren't sent. Signed-off-by: Thomas Böhler commit - 91d924e2ff7408d4e6b66378d7af3bf48cef4a69 commit + 6f8eb2710134cde1501dfca708fda3d16d9ab578 blob - 27647b749a7d30aaed1c384cbb69766e882b6935 blob + 4edbfe45d73e6a659b7ef084fc113a6a6fbd6406 --- src/main.rs +++ src/main.rs @@ -173,6 +173,7 @@ async fn sender( config: &AppConfig, mut conn: PoolConnection, mut rx: Receiver, + dry_run: bool, ) -> Result<(), Error> { let mailer = get_mailer( config.smtp_user.clone(), @@ -190,6 +191,7 @@ async fn sender( &config.mail_from, &config.mail_to, post, + dry_run, ) .await?; } @@ -226,10 +228,8 @@ async fn app_main() -> Result<(), Error> { } let conn = pool.acquire().await.context(GeneralDatabaseSnafu)?; join_set.spawn(async move { accumulator(conn, acc_rx, acc_tx).await }); - if !config.dry_run { - let conn = pool.acquire().await.context(GeneralDatabaseSnafu)?; - join_set.spawn(async move { sender(&config, conn, send_rx).await }); - } + let conn = pool.acquire().await.context(GeneralDatabaseSnafu)?; + join_set.spawn(async move { sender(&config, conn, send_rx, config.dry_run).await }); while let Some(task) = join_set.join_next().await { if let Err(e) = task { @@ -246,12 +246,15 @@ async fn send_post<'a>( from: &'a str, to: &'a str, post: models::Post, + dry_run: bool, ) -> Result<(), Error> { - log::debug!("Sending post with guid '{}'", post.guid); - Mail::new(post.title, post.content, post.url) - .send_email(from, to, &mailer) - .await - .context(MailSnafu)?; + if !dry_run { + log::debug!("Sending post with guid '{}'", post.guid); + Mail::new(post.title, post.content, post.url) + .send_email(from, to, &mailer) + .await + .context(MailSnafu)?; + } set_sent(&post.guid, conn).await?;