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