This commit is contained in:
jess 2026-04-25 13:55:51 -07:00
parent 24054058ad
commit 6f3461730e
2 changed files with 13 additions and 1 deletions

View File

@ -27,6 +27,7 @@ fn main() {
tracing::info!(
plugin_root = ?plugin_root,
data_dir = ?layers::paths::data_dir(),
log_dir = ?layers::paths::log_dir(),
"layers shell: starting native event loop",
);

View File

@ -5,6 +5,7 @@ use sha2::{Digest, Sha256};
const PLUGIN_ID: &str = "com.jesshunter.layers";
const KICAD_MAJOR_DIR: &str = "KiCad/10.0/plugins";
const USER_DATA_DOTDIR: &str = ".layers";
pub fn plugin_data_dir() -> PathBuf {
plugin_root()
@ -14,8 +15,18 @@ pub fn plugin_dir() -> PathBuf {
plugin_root()
}
/// User-writable runtime data root: logs, state, cache, settings, runtime sockets.
/// Decoupled from the plugin install location so a flatpak KiCad (which sandboxes
/// its own data dirs) still writes somewhere we can `tail -f` from a normal shell.
pub fn data_dir() -> PathBuf {
plugin_root()
if let Ok(v) = std::env::var("LAYERS_DATA_DIR") {
if !v.is_empty() {
return PathBuf::from(v);
}
}
dirs::home_dir()
.map(|h| h.join(USER_DATA_DOTDIR))
.unwrap_or_else(|| PathBuf::from("/tmp").join(USER_DATA_DOTDIR))
}
pub fn state_dir() -> PathBuf {