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:
Siavash Sameni
2026-03-26 22:27:49 +04:00
parent 94b845eb5b
commit 722441c391
4 changed files with 21 additions and 12 deletions

View File

@@ -58,10 +58,7 @@ pub fn run() -> Result<()> {
// Store bundle locally for later registration
let bundle_bytes = bincode::serialize(&bundle)?;
let home = std::env::var("HOME").unwrap_or_else(|_| ".".into());
let bundle_path = std::path::Path::new(&home)
.join(".warzone")
.join("bundle.bin");
let bundle_path = crate::keystore::data_dir().join("bundle.bin");
std::fs::write(&bundle_path, &bundle_bytes)?;
println!("\nTo register with a server, run:");
@@ -81,10 +78,7 @@ pub async fn register_with_server(server_url: &str) -> Result<()> {
let pub_id = identity.public_identity();
let fp = pub_id.fingerprint.to_string();
let home = std::env::var("HOME").unwrap_or_else(|_| ".".into());
let bundle_path = std::path::Path::new(&home)
.join(".warzone")
.join("bundle.bin");
let bundle_path = crate::keystore::data_dir().join("bundle.bin");
let bundle_bytes = std::fs::read(&bundle_path)
.map_err(|_| anyhow::anyhow!("No bundle found. Run `warzone init` first."))?;