From 078a77e3056dbf34f3dea68ceb6d23721faf557c Mon Sep 17 00:00:00 2001 From: Aspect Date: Sat, 7 Jun 2025 15:56:13 -0400 Subject: [PATCH] Windows: update config file location --- README.md | 2 +- src/main.rs | 2 +- src/windows_service.rs | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 21e68e0..1208d28 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ sc start Tenebra However, Tenebra reads from a config file which must be populated before running Tenebra. If it is not populated, Tenebra will fail before copying the default config file to the config file directory. * On **Linux** the config file is at `$XDG_CONFIG_HOME`/tenebra/config.toml or `$HOME`/.config/tenebra/config.toml (e.g. /home/alice/.config/tenebra/config.toml) -* On **Windows** the config file is at `{FOLDERID_RoamingAppData}` (e.g. C:\Users\Alice\AppData\Roaming) +* On **Windows** the config file is at `C:\tenebra\config.toml` * On **macOS** the config file is at `$HOME`/Library/Application Support (e.g. /Users/Alice/Library/Application Support) [See the default config file.](src/default.toml) diff --git a/src/main.rs b/src/main.rs index b188c80..a927a4a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -504,7 +504,7 @@ async fn entrypoint() -> Result<()> { config_path.push("config.toml"); #[cfg(target_os = "windows")] - let mut config_path = std::path::Path::new("C:\\tenebra.toml"); + let mut config_path = std::path::Path::new("C:\\tenebra\\config.toml"); #[cfg(not(target_os = "windows"))] std::fs::create_dir_all(&config_path).context("Failed to create config directory")?; diff --git a/src/windows_service.rs b/src/windows_service.rs index 9d8ec66..6be8e36 100644 --- a/src/windows_service.rs +++ b/src/windows_service.rs @@ -25,6 +25,8 @@ use std::cell::Cell; use std::time::Duration; use std::ffi::{OsStr, OsString}; use std::os::windows::ffi::OsStrExt; +use std::io::Write; +use std::fs::{File, create_dir_all}; const SERVICE_NAME: &str = "Tenebra"; const SERVICE_TYPE: ServiceType = ServiceType::OWN_PROCESS; @@ -57,8 +59,8 @@ pub fn run() -> Result<()> { define_windows_service!(ffi_service_main, service_main); pub fn service_main(_arguments: Vec) { - use std::io::Write; - let mut file = std::fs::File::create("C:\\tenebra_log.txt").unwrap(); + create_dir_all("C:\\tenebra").unwrap(); + let mut file = File::create("C:\\tenebra\\tenebra_log.txt").unwrap(); unsafe { std::env::set_var("RUST_BACKTRACE", "1"); } if let Err(e) = run_service() { writeln!(&mut file, "Error: {:?}", e).unwrap();