H6: isolated data directory for dev and live-check instances
`--data-dir DIR` / `LUTRA_DATA_DIR` move settings, the recovery journal, the rendezvous file and the WebView2 user data folder into one directory. `--control PORT` without either uses `<temp>/lutra-control/<port>/`. The SHA-256-checked Phpactor cache stays shared from the user's data dir (`Engine::share_tools_from`). An isolated instance never forwards to or registers as the user's main instance; `rendezvous::dir()` honours `LUTRA_DATA_DIR` after `LUTRA_RENDEZVOUS_DIR`, so the CLI finds it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e5891ddeb4
commit
ba70b0f43a
10 changed files with 418 additions and 29 deletions
|
|
@ -14,7 +14,8 @@
|
|||
//! that ACL. A file whose listener does not answer, or answers without
|
||||
//! accepting the token, is stale: the next app start replaces it.
|
||||
//!
|
||||
//! The directory is [`dir`]: `LUTRA_RENDEZVOUS_DIR` if set, otherwise
|
||||
//! The directory is [`dir`]: `LUTRA_RENDEZVOUS_DIR` if set, otherwise the
|
||||
//! isolated data directory `LUTRA_DATA_DIR` if set, otherwise
|
||||
//! [`default_data_dir`], which matches Tauri's `app_data_dir()` for the
|
||||
//! identifier [`APP_IDENTIFIER`].
|
||||
|
||||
|
|
@ -32,6 +33,13 @@ pub const FILE_NAME: &str = "instance.json";
|
|||
/// takes part in the single instance only when it is set.
|
||||
pub const DIR_ENV: &str = "LUTRA_RENDEZVOUS_DIR";
|
||||
|
||||
/// Environment variable that moves a desktop instance's whole data
|
||||
/// directory (settings, recovery journal, rendezvous file, webview data)
|
||||
/// away from the user's, like the desktop's `--data-dir PATH`. Such an
|
||||
/// instance is isolated: it never forwards to or registers as the user's
|
||||
/// main instance. The CLI looks for the rendezvous file there too.
|
||||
pub const DATA_DIR_ENV: &str = "LUTRA_DATA_DIR";
|
||||
|
||||
/// The Tauri app identifier, the last part of the data directory.
|
||||
pub const APP_IDENTIFIER: &str = "dev.lutra.desktop";
|
||||
|
||||
|
|
@ -79,12 +87,17 @@ impl std::fmt::Display for ReadError {
|
|||
impl std::error::Error for ReadError {}
|
||||
|
||||
/// The rendezvous directory: `LUTRA_RENDEZVOUS_DIR` if set and not empty,
|
||||
/// otherwise [`default_data_dir`].
|
||||
/// otherwise `LUTRA_DATA_DIR` if set and not empty (made absolute against
|
||||
/// the current directory), otherwise [`default_data_dir`].
|
||||
pub fn dir() -> Option<PathBuf> {
|
||||
match std::env::var_os(DIR_ENV) {
|
||||
Some(value) if !value.is_empty() => Some(PathBuf::from(value)),
|
||||
_ => default_data_dir(),
|
||||
}
|
||||
let set = |name: &str| {
|
||||
std::env::var_os(name)
|
||||
.filter(|value| !value.is_empty())
|
||||
.map(PathBuf::from)
|
||||
};
|
||||
set(DIR_ENV)
|
||||
.or_else(|| set(DATA_DIR_ENV).map(|p| std::path::absolute(&p).unwrap_or(p)))
|
||||
.or_else(default_data_dir)
|
||||
}
|
||||
|
||||
/// The app data directory as Tauri computes it for [`APP_IDENTIFIER`]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue