aboutsummaryrefslogtreecommitdiffstats
path: root/src/commands/utilities.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/commands/utilities.rs15
1 files changed, 11 insertions, 4 deletions
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 @@
1use std::time::Duration;
2
1use poise::serenity_prelude as serenity; 3use poise::serenity_prelude as serenity;
2use tracing::warn; 4use tracing::warn;
3 5
@@ -524,10 +526,15 @@ async fn run_download(
524 } 526 }
525 cmd.arg("--").arg(sanitize_yt_url(url)); 527 cmd.arg("--").arg(sanitize_yt_url(url));
526 528
527 let output = cmd 529 let output = match tokio::time::timeout(Duration::from_secs(600), cmd.output()).await {
528 .output() 530 Ok(result) => result.map_err(|e| Error::Custom(lang::fmt_ytdlp_err(&e)))?,
529 .await 531 Err(_) => {
530 .map_err(|e| Error::Custom(lang::fmt_ytdlp_err(&e)))?; 532 let _ = tokio::fs::remove_dir_all(&dl_dir).await;
533 ctx.say(lang::fmt_download_failed("download timed out after 10 minutes"))
534 .await?;
535 return Ok(());
536 }
537 };
531 if !output.status.success() { 538 if !output.status.success() {
532 let stderr = String::from_utf8_lossy(&output.stderr); 539 let stderr = String::from_utf8_lossy(&output.stderr);
533 // Keep the full yt-dlp trace in the logs; the user only sees the 540 // Keep the full yt-dlp trace in the logs; the user only sees the