ripasso-cursive: cosmetic changes (#361736)
[NixPkgs.git] / pkgs / by-name / di / dim / relative-paths.diff
blobe5f27c7f1715a8a47b175b41a50ae8bea01e5f3b
1 diff --git a/dim-core/src/routes/settings.rs b/dim-core/src/routes/settings.rs
2 index f577eaf6..67da9448 100644
3 --- a/dim-core/src/routes/settings.rs
4 +++ b/dim-core/src/routes/settings.rs
5 @@ -1,5 +1,3 @@
6 -use crate::utils::ffpath;
8 use std::error::Error;
9 use std::fs::File;
10 use std::fs::OpenOptions;
11 @@ -49,7 +47,7 @@ impl Default for GlobalSettings {
15 - metadata_dir: ffpath("config/metadata"),
16 + metadata_dir: "config/metadata".into(),
17 quiet_boot: false,
18 disable_auth: false,
19 verbose: false,
20 @@ -69,7 +67,7 @@ pub fn get_global_settings() -> GlobalSettings {
23 pub fn init_global_settings(path: Option<String>) -> Result<(), Box<dyn Error>> {
24 - let path = path.unwrap_or(ffpath("config/config.toml"));
25 + let path = path.unwrap_or("config/config.toml".into());
26 let _ = SETTINGS_PATH.set(path.clone());
27 let mut content = String::new();
29 @@ -94,7 +92,7 @@ pub fn set_global_settings(settings: GlobalSettings) -> Result<(), Box<dyn Error
30 let path = SETTINGS_PATH
31 .get()
32 .cloned()
33 - .unwrap_or(ffpath("config/config.toml"));
34 + .unwrap_or("config/config.toml".into());
37 let mut lock = GLOBAL_SETTINGS.lock().unwrap();
38 @@ -107,4 +105,4 @@ pub fn set_global_settings(settings: GlobalSettings) -> Result<(), Box<dyn Error
39 .unwrap();
41 Ok(())
43 \ No newline at end of file
45 diff --git a/dim-core/src/streaming/mod.rs b/dim-core/src/streaming/mod.rs
46 index a9312041..8ad12fe4 100644
47 --- a/dim-core/src/streaming/mod.rs
48 +++ b/dim-core/src/streaming/mod.rs
49 @@ -1,27 +1,13 @@
50 pub mod ffprobe;
52 -use cfg_if::cfg_if;
54 use std::collections::HashMap;
55 use std::sync::Arc;
56 use std::sync::RwLock;
58 -use crate::utils::ffpath;
60 lazy_static::lazy_static! {
61 pub static ref STREAMING_SESSION: Arc<RwLock<HashMap<String, HashMap<String, String>>>> = Arc::new(RwLock::new(HashMap::new()));
62 - pub static ref FFMPEG_BIN: &'static str = Box::leak(ffpath("utils/ffmpeg").into_boxed_str());
63 - pub static ref FFPROBE_BIN: &'static str = {
64 - cfg_if! {
65 - if #[cfg(test)] {
66 - "/usr/bin/ffprobe"
67 - } else if #[cfg(bench)] {
68 - "/usr/bin/ffprobe"
69 - } else {
70 - Box::leak(ffpath("utils/ffprobe").into_boxed_str())
71 - }
72 - }
73 - };
74 + pub static ref FFMPEG_BIN: &'static str = "ffmpeg";
75 + pub static ref FFPROBE_BIN: &'static str = "ffprobe";
78 use std::process::Command;
79 diff --git a/dim-database/src/lib.rs b/dim-database/src/lib.rs
80 index de99a5e4..ac9731be 100644
81 --- a/dim-database/src/lib.rs
82 +++ b/dim-database/src/lib.rs
83 @@ -1,8 +1,6 @@
84 // FIXME: We have a shim in dim/utils but we cant depend on dim because itd be a circular dep.
85 #![deny(warnings)]
87 -use crate::utils::ffpath;
89 use std::str::FromStr;
90 use std::sync::atomic::AtomicBool;
91 use std::sync::atomic::Ordering;
92 @@ -157,13 +155,13 @@ pub async fn get_conn_logged() -> sqlx::Result<DbConnection> {
93 async fn internal_get_conn() -> sqlx::Result<DbConnection> {
94 let rw_only = sqlx::sqlite::SqliteConnectOptions::new()
95 .create_if_missing(true)
96 - .filename(ffpath("config/dim.db"))
97 + .filename("config/dim.db")
98 .connect()
99 .await?;
101 let rd_only = sqlx::pool::PoolOptions::new()
102 .connect_with(
103 - sqlx::sqlite::SqliteConnectOptions::from_str(ffpath("config/dim.db"))?
104 + sqlx::sqlite::SqliteConnectOptions::from_str("config/dim.db")?
105 .read_only(true)
106 .synchronous(sqlx::sqlite::SqliteSynchronous::Normal)
107 .create_if_missing(true),
108 diff --git a/dim-database/src/utils.rs b/dim-database/src/utils.rs
109 index 35e25c6c..e1e56e01 100644
110 --- a/dim-database/src/utils.rs
111 +++ b/dim-database/src/utils.rs
112 @@ -16,17 +16,3 @@ macro_rules! opt_update {
117 -#[cfg(not(debug_assertions))]
118 -pub fn ffpath(bin: impl AsRef<str>) -> &'static str {
119 - let mut path = std::env::current_exe().expect("Failed to grab path to the `dim` binary.");
120 - path.pop(); // remove the dim bin to get the dir of `dim`
121 - path.push(bin.as_ref());
123 - Box::leak(path.to_string_lossy().to_string().into_boxed_str())
126 -#[cfg(debug_assertions)]
127 -pub fn ffpath(bin: impl AsRef<str>) -> &'static str {
128 - Box::leak(bin.as_ref().to_string().into_boxed_str())
130 diff --git a/dim-utils/src/lib.rs b/dim-utils/src/lib.rs
131 index 816bfe82..6dddc9aa 100644
132 --- a/dim-utils/src/lib.rs
133 +++ b/dim-utils/src/lib.rs
134 @@ -400,20 +400,6 @@ pub fn secs_to_pretty(t: u64) -> String {
138 -#[cfg(not(debug_assertions))]
139 -pub fn ffpath(bin: impl AsRef<str>) -> String {
140 - let mut path = std::env::current_exe().expect("Failed to grab path to the `dim` binary.");
141 - path.pop(); // remove the dim bin to get the dir of `dim`
142 - path.push(bin.as_ref());
144 - path.to_string_lossy().to_string()
147 -#[cfg(debug_assertions)]
148 -pub fn ffpath(bin: impl AsRef<str>) -> String {
149 - bin.as_ref().to_string()
152 pub fn codec_pretty(codec: &str) -> String {
153 match codec {
154 "h264" => "H.264".into(),
155 diff --git a/dim/src/main.rs b/dim/src/main.rs
156 index 867d64de..e683b441 100644
157 --- a/dim/src/main.rs
158 +++ b/dim/src/main.rs
159 @@ -18,12 +18,12 @@ struct Args {
161 fn main() {
162 let args = Args::parse();
163 - let _ = std::fs::create_dir_all(dim::utils::ffpath("config"));
164 + let _ = std::fs::create_dir_all("config");
166 let config_path = args
167 .config
168 .map(|x| x.to_string_lossy().to_string())
169 - .unwrap_or(dim::utils::ffpath("config/config.toml"));
170 + .unwrap_or("config/config.toml".into());
172 // initialize global settings.
173 dim::init_global_settings(Some(config_path)).expect("Failed to initialize global settings.");