Save presets beside the settings, not under a raw HOME

PresetStore::open built its path from XDG_CONFIG_HOME or HOME. Android
sets neither, so the library resolved to /.config/darkroom, which is
read-only, and every preset saved on the tablet failed. Windows sets no
HOME either and got a directory relative to the working directory. The
settings store was moved to dr_sync::account::config_dir for the same
reason in 0.12.1; the presets now follow it. Linux and macOS resolve to
the same file as before.
This commit is contained in:
2026-10-04 00:49:59 -04:00
parent 25dc0d0179
commit 26e50ae723
+7 -10
View File
@@ -27,17 +27,14 @@ pub struct PresetStore {
impl PresetStore {
/// Open the store at the platform config location.
///
/// Linux: `$XDG_CONFIG_HOME/darkroom/presets.drpl`, falling back to
/// `~/.config` — the same resolution `SettingsStore` does, so the files sit
/// together and a user backing up one takes all of them.
/// Beside `settings.json`, in [`dr_sync::account::config_dir`], so a user
/// backing up one takes all of them. Never from `HOME` directly: Android
/// declares its data directory rather than setting `HOME`, and a path
/// built from an empty one is `/.config`, which is read-only — every
/// preset saved on the tablet failed. Windows sets no `HOME` either, and
/// got a directory relative to wherever the app was started.
pub fn open() -> Self {
let dir = std::env::var_os("XDG_CONFIG_HOME")
.map(PathBuf::from)
.unwrap_or_else(|| {
PathBuf::from(std::env::var("HOME").unwrap_or_default()).join(".config")
})
.join("darkroom");
Self::open_at(dir.join(format!(
Self::open_at(dr_sync::account::config_dir().join(format!(
"presets.{}",
dr_pipeline::preset::LIBRARY_EXTENSION
)))