From fd93334a21907f959018e1b1f5df747a98d186c8 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 4 Nov 2026 01:11:50 +0100 Subject: processes: add timeouts and keep decoding off the runtime --- src/commands/utilities.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/commands/utilities.rs') diff --git a/src/commands/utilities.rs b/src/commands/utilities.rs index bf93491..c26fd0e 100644 --- a/src/commands/utilities.rs +++ b/src/commands/utilities.rs @@ -1,3 +1,5 @@ +use std::time::Duration; + use poise::serenity_prelude as serenity; use tracing::warn; @@ -524,10 +526,15 @@ async fn run_download( } cmd.arg("--").arg(sanitize_yt_url(url)); - let output = cmd - .output() - .await - .map_err(|e| Error::Custom(lang::fmt_ytdlp_err(&e)))?; + let output = match tokio::time::timeout(Duration::from_secs(600), cmd.output()).await { + Ok(result) => result.map_err(|e| Error::Custom(lang::fmt_ytdlp_err(&e)))?, + Err(_) => { + let _ = tokio::fs::remove_dir_all(&dl_dir).await; + ctx.say(lang::fmt_download_failed("download timed out after 10 minutes")) + .await?; + return Ok(()); + } + }; if !output.status.success() { let stderr = String::from_utf8_lossy(&output.stderr); // Keep the full yt-dlp trace in the logs; the user only sees the -- cgit v1.2.3