chromium,chromedriver: 129.0.6668.91 -> 129.0.6668.100
[NixPkgs.git] / pkgs / by-name / un / uni-sync / config_path.patch
blobc59bf80125ae06d8030a0b08abc2ccd930fb7e4d
1 diff --git a/src/main.rs b/src/main.rs
2 index 357a33b..7073497 100644
3 --- a/src/main.rs
4 +++ b/src/main.rs
5 @@ -1,4 +1,4 @@
6 -use std::env;
7 +use std::path::PathBuf;
9 mod devices;
11 @@ -8,12 +8,23 @@ fn main() -> Result<(), std::io::Error> {
12 configs: vec![]
15 - let mut config_path = env::current_exe()?;
16 - config_path.pop();
17 - config_path.push("uni-sync.json");
18 + let mut config_path = PathBuf::from("/etc/uni-sync/uni-sync.json");
20 if !config_path.exists() {
21 - std::fs::write(&config_path, serde_json::to_string_pretty(&configs).unwrap())?;
22 + match std::fs::create_dir_all(config_path.parent().unwrap()) {
23 + Ok(result) => result,
24 + Err(_) => {
25 + println!("Please run uni-sync with elevated permissions.");
26 + std::process::exit(0);
27 + }
28 + };
29 + match std::fs::write(&config_path, serde_json::to_string_pretty(&configs).unwrap()) {
30 + Ok(result) => result,
31 + Err(_) => {
32 + println!("Please run uni-sync with elevated permissions.");
33 + std::process::exit(0);
34 + }
35 + };
38 let config_content = std::fs::read_to_string(&config_path).unwrap();