From b68aef83badfe9d26fb85ed6bf278e07eda506be Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Sun, 15 Mar 2026 19:55:52 +0100 Subject: [PATCH] fix(frecency): warn+disable instead of cwd fallback when XDG unavailable --- crates/plugins/plugin-apps/Cargo.toml | 1 + crates/plugins/plugin-apps/src/frecency.rs | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/plugins/plugin-apps/Cargo.toml b/crates/plugins/plugin-apps/Cargo.toml index 1631674..0c7511e 100644 --- a/crates/plugins/plugin-apps/Cargo.toml +++ b/crates/plugins/plugin-apps/Cargo.toml @@ -13,6 +13,7 @@ k-launcher-kernel = { path = "../../k-launcher-kernel" } serde = { workspace = true } serde_json = "1.0" tokio = { workspace = true } +tracing = { workspace = true } [target.'cfg(target_os = "linux")'.dependencies] xdg = "3" diff --git a/crates/plugins/plugin-apps/src/frecency.rs b/crates/plugins/plugin-apps/src/frecency.rs index 6f57e9a..c7e2160 100644 --- a/crates/plugins/plugin-apps/src/frecency.rs +++ b/crates/plugins/plugin-apps/src/frecency.rs @@ -36,11 +36,14 @@ impl FrecencyStore { } pub fn load() -> Arc { - let path = xdg::BaseDirectories::new() - .get_data_home() - .unwrap_or_else(|| PathBuf::from(".")) - .join("k-launcher") - .join("frecency.json"); + let Some(data_home) = xdg::BaseDirectories::new().get_data_home() else { + tracing::warn!("XDG_DATA_HOME unavailable; frecency disabled (in-memory only)"); + return Arc::new(Self { + path: PathBuf::from("/dev/null"), + data: Mutex::new(HashMap::new()), + }); + }; + let path = data_home.join("k-launcher").join("frecency.json"); Self::new(path) }