Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions openless-all/app/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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");
}
}
Expand All @@ -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");
}
}
Expand All @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion openless-all/app/src-tauri/src/persistence/credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<openless_core::credentials::SyncWriteGate>,
Expand Down
25 changes: 21 additions & 4 deletions openless-all/app/src-tauri/src/persistence/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,34 +58,51 @@ 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<PathBuf> {
#[cfg(target_os = "macos")]
{
let home = std::env::var("HOME").context("HOME not set")?;
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")]
Expand Down
Loading