diff --git a/openless-all/app/src-tauri/src/lib.rs b/openless-all/app/src-tauri/src/lib.rs index e86153098..25bcd5352 100644 --- a/openless-all/app/src-tauri/src/lib.rs +++ b/openless-all/app/src-tauri/src/lib.rs @@ -132,7 +132,7 @@ use std::time::Duration; const LOG_ROTATE_LIMIT_BYTES: u64 = 10 * 1024 * 1024; #[cfg(target_os = "macos")] -const OPENLESS_BUNDLE_ID: &str = "com.openless.app"; +const OPENLESS_BUNDLE_ID: &str = crate::persistence::BUNDLE_ID; /// Positions the QA window at the bottom-center of the screen on first show only, so the /// user-dragged position survives hide → show cycles. See issue #118 v2. @@ -1902,14 +1902,14 @@ pub fn log_dir_path() -> std::path::PathBuf { return std::path::PathBuf::from(home) .join("Library") .join("Logs") - .join("OpenLess"); + .join(crate::persistence::APP_DIR_NAME); } } #[cfg(target_os = "windows")] { if let Ok(local) = std::env::var("LOCALAPPDATA") { return std::path::PathBuf::from(local) - .join("OpenLess") + .join(crate::persistence::APP_DIR_NAME) .join("Logs"); } } @@ -1919,7 +1919,7 @@ pub fn log_dir_path() -> std::path::PathBuf { return std::path::PathBuf::from(home) .join(".local") .join("share") - .join("OpenLess") + .join(crate::persistence::APP_DIR_NAME) .join("logs"); } } @@ -1934,7 +1934,7 @@ pub fn log_dir_path() -> std::path::PathBuf { } #[cfg(not(target_os = "android"))] { - std::env::temp_dir().join("OpenLess") + std::env::temp_dir().join(crate::persistence::APP_DIR_NAME) } } diff --git a/openless-all/app/src-tauri/src/persistence/credentials.rs b/openless-all/app/src-tauri/src/persistence/credentials.rs index e123505ca..192c25e3d 100644 --- a/openless-all/app/src-tauri/src/persistence/credentials.rs +++ b/openless-all/app/src-tauri/src/persistence/credentials.rs @@ -3497,7 +3497,7 @@ pub struct CredentialsVault; impl CredentialsVault { /// System credential store service name; maps to the Keychain service on macOS. - pub const SERVICE_NAME: &'static str = "com.openless.app"; + pub const SERVICE_NAME: &'static str = super::BUNDLE_ID; pub(crate) fn bind_sync_gate( gate: std::sync::Arc, diff --git a/openless-all/app/src-tauri/src/persistence/mod.rs b/openless-all/app/src-tauri/src/persistence/mod.rs index c274ee018..36bd10e84 100644 --- a/openless-all/app/src-tauri/src/persistence/mod.rs +++ b/openless-all/app/src-tauri/src/persistence/mod.rs @@ -58,6 +58,23 @@ pub(crate) use android_storage::{android_log_dir, android_openless_log_candidate const HISTORY_CAP: usize = 200; const PREFERENCES_FILE: &str = "preferences.json"; +/// Bundle identifier; also the system credential store service name. A personal +/// side-by-side build sets `OPENLESS_BUNDLE_ID` at compile time (matching its Tauri +/// identifier) so its permissions and credentials never mix with the official app's. +#[cfg_attr(target_os = "android", allow(dead_code))] +pub(crate) const BUNDLE_ID: &str = match option_env!("OPENLESS_BUNDLE_ID") { + Some(id) => id, + None => "com.openless.app", +}; + +/// Per-user data and log directory name, overridden by `OPENLESS_APP_DIR_NAME` the +/// same way. +#[cfg_attr(target_os = "android", allow(dead_code))] +pub(crate) const APP_DIR_NAME: &str = match option_env!("OPENLESS_APP_DIR_NAME") { + Some(name) => name, + None => "OpenLess", +}; + pub(crate) fn data_dir() -> Result { #[cfg(target_os = "macos")] { @@ -65,27 +82,27 @@ pub(crate) fn data_dir() -> Result { Ok(PathBuf::from(home) .join("Library") .join("Application Support") - .join("OpenLess")) + .join(APP_DIR_NAME)) } #[cfg(target_os = "windows")] { let appdata = std::env::var("APPDATA").context("APPDATA not set")?; - Ok(PathBuf::from(appdata).join("OpenLess")) + Ok(PathBuf::from(appdata).join(APP_DIR_NAME)) } #[cfg(all(unix, not(target_os = "macos"), not(target_os = "android")))] { if let Ok(xdg) = std::env::var("XDG_DATA_HOME") { if !xdg.is_empty() { - return Ok(PathBuf::from(xdg).join("OpenLess")); + return Ok(PathBuf::from(xdg).join(APP_DIR_NAME)); } } let home = std::env::var("HOME").context("HOME not set")?; Ok(PathBuf::from(home) .join(".local") .join("share") - .join("OpenLess")) + .join(APP_DIR_NAME)) } #[cfg(target_os = "android")]