about summary refs log tree commit diff stats
path: root/sys/nixpkgs/pkgs/ytc
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2024-01-06 15:37:11 +0100
committerSoispha <soispha@vhack.eu>2024-01-06 17:11:49 +0100
commit0d63f060f56192c31f355cc1e959a37bd572c75f (patch)
tree3f8b93d6c54b241e0d6e001f4dbab089249b0cbb /sys/nixpkgs/pkgs/ytc
parentdocs(sys/nixpkgs/pkgs/ytc): Slightly improve error output (diff)
downloadnixos-config-0d63f060f56192c31f355cc1e959a37bd572c75f.tar.gz
nixos-config-0d63f060f56192c31f355cc1e959a37bd572c75f.zip
fix(sys/nixpkgs/pkgs/ytc/scr): Create download dir
Diffstat (limited to 'sys/nixpkgs/pkgs/ytc')
-rw-r--r--sys/nixpkgs/pkgs/ytc/src/downloader.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/sys/nixpkgs/pkgs/ytc/src/downloader.rs b/sys/nixpkgs/pkgs/ytc/src/downloader.rs
index 3b0c6670..f1bbd16a 100644
--- a/sys/nixpkgs/pkgs/ytc/src/downloader.rs
+++ b/sys/nixpkgs/pkgs/ytc/src/downloader.rs
@@ -1,4 +1,5 @@
 use std::{
+    fs,
     io::{stderr, stdout, Read},
     mem,
     path::PathBuf,
@@ -117,6 +118,10 @@ fn download_url(url: &str) -> Result<PathBuf> {
         .as_file()
         .set_len(0)
         .context("Failed to truncate temp-file")?;
+    if !Into::<PathBuf>::into(DOWNLOAD_DIR).exists() {
+        fs::create_dir_all(DOWNLOAD_DIR)
+            .with_context(|| format!("Failed to create download dir at: {}", DOWNLOAD_DIR))?
+    }
     let mut yt_dlp = Command::new("yt-dlp");
     yt_dlp.current_dir(DOWNLOAD_DIR);
     yt_dlp.stdout(stdout());