record-daemon: give scripted runs a home of their own

An end-to-end run of mine put its settings through updateSettings, which
wrote them to the user's real config: output path in %TEMP%, a "probe"
application, 30 fps. The next game recorded into %TEMP%, so it showed up
in the history with its metadata and no video beside it.

RECORD_DAEMON_HOME now moves the config directory, the recordings, the
logs and the IPC pipe under one directory. The app reads the same
variable, so a probe talks to the scratch daemon instead of the real one.
Default paths are unchanged.

The daemon also logs its config and recordings paths at startup, which is
the first thing to look at when a recording has no video.
This commit is contained in:
vhaudiquet committed 2026-11-17 00:19:13 +01:00
1 parent 6584b2f92f
commit 2e463dab3a
6 files changed
+71 -8

No files matched your search

+23 -2
View File
@@ -19,14 +19,35 @@ use std::path::PathBuf;
/// Default configuration file name.
pub const CONFIG_FILE_NAME: &str = "config.toml";
/// Set this to run the daemon against a scratch directory instead of the user's config,
/// recordings and log. Scripts and end-to-end tests set it so they cannot touch real data.
pub const HOME_ENV: &str = "RECORD_DAEMON_HOME";
fn override_home() -> Option<PathBuf> {
std::env::var_os(HOME_ENV)
.filter(|value| !value.is_empty())
.map(PathBuf::from)
}
/// Get the default configuration directory.
pub fn get_config_dir() -> Option<PathBuf> {
if let Some(home) = override_home() {
return Some(home.join("config"));
}
directories::ProjectDirs::from("com", "leaguerecorder", "record-daemon")
.map(|dirs| dirs.config_dir().to_path_buf())
}
/// Get the data directory, which holds `recordings` and `logs`.
pub fn get_data_dir() -> Option<PathBuf> {
if let Some(home) = override_home() {
return Some(home.join("data"));
}
directories::ProjectDirs::from("com", "leaguerecorder", "record-daemon")
.map(|dirs| dirs.data_dir().to_path_buf())
}
/// Get the default output directory for recordings.
pub fn get_default_output_dir() -> Option<PathBuf> {
directories::ProjectDirs::from("com", "leaguerecorder", "record-daemon")
.map(|dirs| dirs.data_dir().join("recordings"))
get_data_dir().map(|dir| dir.join("recordings"))
}