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:
@@ -27,17 +27,14 @@ pub struct PresetStore {
|
|||||||
impl PresetStore {
|
impl PresetStore {
|
||||||
/// Open the store at the platform config location.
|
/// Open the store at the platform config location.
|
||||||
///
|
///
|
||||||
/// Linux: `$XDG_CONFIG_HOME/darkroom/presets.drpl`, falling back to
|
/// Beside `settings.json`, in [`dr_sync::account::config_dir`], so a user
|
||||||
/// `~/.config` — the same resolution `SettingsStore` does, so the files sit
|
/// backing up one takes all of them. Never from `HOME` directly: Android
|
||||||
/// together and a user backing up one takes all of them.
|
/// 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 {
|
pub fn open() -> Self {
|
||||||
let dir = std::env::var_os("XDG_CONFIG_HOME")
|
Self::open_at(dr_sync::account::config_dir().join(format!(
|
||||||
.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!(
|
|
||||||
"presets.{}",
|
"presets.{}",
|
||||||
dr_pipeline::preset::LIBRARY_EXTENSION
|
dr_pipeline::preset::LIBRARY_EXTENSION
|
||||||
)))
|
)))
|
||||||
|
|||||||
Reference in New Issue
Block a user