Add WARZONE_HOME env var for separate user data directories
All data paths now use keystore::data_dir() which checks WARZONE_HOME first, falls back to ~/.warzone. This avoids the HOME override hack that breaks rustup/cargo. Usage: WARZONE_HOME=/tmp/bob warzone init Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,9 +6,19 @@ use std::path::PathBuf;
|
||||
|
||||
use warzone_protocol::identity::Seed;
|
||||
|
||||
/// Get the warzone data directory. Respects WARZONE_HOME env var,
|
||||
/// falls back to ~/.warzone.
|
||||
pub fn data_dir() -> PathBuf {
|
||||
if let Ok(wz) = std::env::var("WARZONE_HOME") {
|
||||
PathBuf::from(wz)
|
||||
} else {
|
||||
let home = std::env::var("HOME").unwrap_or_else(|_| ".".into());
|
||||
PathBuf::from(home).join(".warzone")
|
||||
}
|
||||
}
|
||||
|
||||
fn seed_path() -> PathBuf {
|
||||
let home = std::env::var("HOME").unwrap_or_else(|_| ".".into());
|
||||
PathBuf::from(home).join(".warzone").join("identity.seed")
|
||||
data_dir().join("identity.seed")
|
||||
}
|
||||
|
||||
pub fn save_seed(seed: &Seed) -> anyhow::Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user