fix(frecency): warn+disable instead of cwd fallback when XDG unavailable
This commit is contained in:
@@ -13,6 +13,7 @@ k-launcher-kernel = { path = "../../k-launcher-kernel" }
|
|||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
|
tracing = { workspace = true }
|
||||||
|
|
||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
xdg = "3"
|
xdg = "3"
|
||||||
|
|||||||
@@ -36,11 +36,14 @@ impl FrecencyStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn load() -> Arc<Self> {
|
pub fn load() -> Arc<Self> {
|
||||||
let path = xdg::BaseDirectories::new()
|
let Some(data_home) = xdg::BaseDirectories::new().get_data_home() else {
|
||||||
.get_data_home()
|
tracing::warn!("XDG_DATA_HOME unavailable; frecency disabled (in-memory only)");
|
||||||
.unwrap_or_else(|| PathBuf::from("."))
|
return Arc::new(Self {
|
||||||
.join("k-launcher")
|
path: PathBuf::from("/dev/null"),
|
||||||
.join("frecency.json");
|
data: Mutex::new(HashMap::new()),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
let path = data_home.join("k-launcher").join("frecency.json");
|
||||||
Self::new(path)
|
Self::new(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user