forked from Keelrleek/SoulStream
a second instance on one machine: its own data, its own peer port, and a join that says itself again when it was never seated
This commit is contained in:
1 parent
67e52697b2
commit
6f7452c803
17 files changed
+125
-56
No files matched your search
@@ -0,0 +1,36 @@
|
||||
//! Where this instance keeps everything it writes.
|
||||
//!
|
||||
//! One directory holds the library, the caches and the whole Freenet side —
|
||||
//! persona, ledgers, node config and data. In a **debug build** the
|
||||
//! `SOULSTREAM_DATA_DIR` environment variable moves it, and that is what makes
|
||||
//! a second instance possible on one machine.
|
||||
//!
|
||||
//! That matters more than a convenience: most of the Community track is
|
||||
//! two-sided and cannot be exercised with one account at all. Accepting a
|
||||
//! friend request, a Space invitation and the join that answers it, removing a
|
||||
//! member, rotating an epoch key, a proposal ping actually arriving — every one
|
||||
//! of those had only unit tests until there was a second instance to talk to.
|
||||
//!
|
||||
//! A release build ignores the variable. An app whose data directory can be
|
||||
//! redirected from the environment is an app whose identity can be redirected
|
||||
//! from the environment, and the persona lives down there.
|
||||
//!
|
||||
//! A second instance also needs its own **node port** (`freenet_ws_port` in its
|
||||
//! config, which the app now passes through to the peer it spawns) and, for
|
||||
//! CDP, its own `SOULSTREAM_CDP_PORT`. Nothing else is shared: two instances
|
||||
//! must never point at one library.db.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use tauri::Manager;
|
||||
|
||||
/// The root this instance writes under.
|
||||
pub fn app_data(app: &tauri::AppHandle) -> Result<PathBuf, String> {
|
||||
#[cfg(debug_assertions)]
|
||||
if let Some(dir) = std::env::var_os("SOULSTREAM_DATA_DIR") {
|
||||
let dir = PathBuf::from(dir);
|
||||
std::fs::create_dir_all(&dir).map_err(|e| format!("SOULSTREAM_DATA_DIR: {e}"))?;
|
||||
return Ok(dir);
|
||||
}
|
||||
app.path().app_data_dir().map_err(|e| e.to_string())
|
||||
}
|
||||
Reference in new issue
Block a user