diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-04 01:11:50 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-04 01:11:50 +0100 |
| commit | fd93334a21907f959018e1b1f5df747a98d186c8 (patch) | |
| tree | 259e595a570b42a5ea082f596e1cb97e5011cfba /src/commands/utilities.rs | |
| parent | http: add connect and request timeouts (diff) | |
| download | senator-sperma-fd93334a21907f959018e1b1f5df747a98d186c8.tar.gz senator-sperma-fd93334a21907f959018e1b1f5df747a98d186c8.zip | |
processes: add timeouts and keep decoding off the runtime
Diffstat (limited to '')
| -rw-r--r-- | src/commands/utilities.rs | 15 |
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 @@ | |||
| 1 | use std::time::Duration; | ||
| 2 | |||
| 1 | use poise::serenity_prelude as serenity; | 3 | use poise::serenity_prelude as serenity; |
| 2 | use tracing::warn; | 4 | use 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 |
