From 6c9286857ef8b314962b67f4a16a66e8c35531bc Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Mon, 14 Oct 2024 14:56:29 +0200 Subject: refactor(treewide): Combine the separate crates in one workspace --- src/config/default.rs | 102 -------------------------------------------------- 1 file changed, 102 deletions(-) delete mode 100644 src/config/default.rs (limited to 'src/config/default.rs') diff --git a/src/config/default.rs b/src/config/default.rs deleted file mode 100644 index 59063f5..0000000 --- a/src/config/default.rs +++ /dev/null @@ -1,102 +0,0 @@ -// yt - A fully featured command line YouTube client -// -// Copyright (C) 2024 Benedikt Peetz -// SPDX-License-Identifier: GPL-3.0-or-later -// -// This file is part of Yt. -// -// You should have received a copy of the License along with this program. -// If not, see . - -use std::path::PathBuf; - -use anyhow::{Context, Result}; - -fn get_runtime_path(name: &'static str) -> Result { - let xdg_dirs = xdg::BaseDirectories::with_prefix(PREFIX)?; - xdg_dirs - .place_runtime_file(name) - .with_context(|| format!("Failed to place runtime file: '{}'", name)) -} -fn get_data_path(name: &'static str) -> Result { - let xdg_dirs = xdg::BaseDirectories::with_prefix(PREFIX)?; - xdg_dirs - .place_data_file(name) - .with_context(|| format!("Failed to place data file: '{}'", name)) -} -fn get_config_path(name: &'static str) -> Result { - let xdg_dirs = xdg::BaseDirectories::with_prefix(PREFIX)?; - xdg_dirs - .place_config_file(name) - .with_context(|| format!("Failed to place config file: '{}'", name)) -} - -pub(super) fn create_path(path: PathBuf) -> Result { - if !path.exists() { - if let Some(parent) = path.parent() { - std::fs::create_dir_all(parent) - .with_context(|| format!("Failed to create the '{}' directory", path.display()))? - } - } - - Ok(path) -} - -pub const PREFIX: &str = "yt"; - -pub mod select { - pub fn playback_speed() -> f64 { - 2.7 - } - pub fn subtitle_langs() -> &'static str { - "" - } -} - -pub mod watch { - pub fn local_comments_length() -> usize { - 1000 - } -} - -pub mod update { - pub fn max_backlog() -> u32 { - 20 - } -} - -pub mod paths { - use std::{env::temp_dir, path::PathBuf}; - - use anyhow::Result; - - use super::{create_path, get_config_path, get_data_path, get_runtime_path, PREFIX}; - - // We download to the temp dir to avoid taxing the disk - pub fn download_dir() -> Result { - let temp_dir = temp_dir(); - - create_path(temp_dir.join(PREFIX)) - } - pub fn mpv_config_path() -> Result { - get_config_path("mpv.conf") - } - pub fn mpv_input_path() -> Result { - get_config_path("mpv.input.conf") - } - pub fn database_path() -> Result { - get_data_path("videos.sqlite") - } - pub fn config_path() -> Result { - get_config_path("config.toml") - } - pub fn last_selection_path() -> Result { - get_runtime_path("selected.yts") - } -} - -pub mod download { - pub fn max_cache_size() -> &'static str { - "3 GiB" - } -} -- cgit 1.4.1