diff options
Diffstat (limited to '')
-rw-r--r-- | sys/nixpkgs/pkgs/yt/src/constants.rs | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/sys/nixpkgs/pkgs/yt/src/constants.rs b/sys/nixpkgs/pkgs/yt/src/constants.rs index 5250820c..6385df54 100644 --- a/sys/nixpkgs/pkgs/yt/src/constants.rs +++ b/sys/nixpkgs/pkgs/yt/src/constants.rs @@ -1,6 +1,6 @@ use std::{env, fs, path::PathBuf}; -pub const HELP_STR: &'static str = include_str!("./help.str"); +pub const HELP_STR: &str = include_str!("./help.str"); pub const YT_DLP_FLAGS: [&str; 13] = [ // Ignore errors arising of unavailable sponsor block API @@ -24,26 +24,23 @@ pub const CONCURRENT: u32 = 5; pub const DOWNLOAD_DIR: &str = "/tmp/ytcc"; -const STATUS_PATH: &str = "ytcc/running"; -pub fn status_path() -> anyhow::Result<PathBuf> { +fn get_runtime_path(component: &'static str) -> anyhow::Result<PathBuf> { let out: PathBuf = format!( "{}/{}", env::var("XDG_RUNTIME_DIR").expect("This should always exist"), - STATUS_PATH + component ) .into(); - fs::create_dir_all(&out.parent().expect("Parent should exist"))?; + fs::create_dir_all(out.parent().expect("Parent should exist"))?; Ok(out) } +const STATUS_PATH: &str = "ytcc/running"; +pub fn status_path() -> anyhow::Result<PathBuf> { + get_runtime_path(STATUS_PATH) +} + const LAST_SELECT: &str = "ytcc/selected.yts"; pub fn last_select() -> anyhow::Result<PathBuf> { - let out: PathBuf = format!( - "{}/{}", - env::var("XDG_RUNTIME_DIR").expect("This should always exist"), - LAST_SELECT - ) - .into(); - fs::create_dir_all(&out.parent().expect("Parent should exist"))?; - Ok(out) + get_runtime_path(LAST_SELECT) } |