synology_apm_repo.sdk.profiles.config_file module

JSON persistence for a profile’s non-secret fields.

Plain, synchronous file I/O — the same shape as LocalFsStore’s own syscalls, which is why the async boundary for this whole package lives one layer up, in profiles/__init__.py’s facade (wrapping calls here in asyncio.to_thread()), not in this module itself.

One file, profiles.json, under a per-user config directory shared by the CLI and TUI alike: $XDG_CONFIG_HOME/synology-apm-repo (falling back to ~/.config/synology-apm-repo) on every platform, not a platform-native config directory — the three-distribution family name, not this SDK distribution’s own name, since both other distributions read/write the exact same file. XDG-everywhere rather than a per-OS-native location (~/Library/Application Support/... on macOS, %APPDATA% on Windows), down to “non-empty and absolute” being the only accepted override of the default: this project’s audience already runs other XDG-convention CLI tooling and expects one predictable config location, not a platform-specific one.

synology_apm_repo.sdk.profiles.config_file.default_config_dir()
synology_apm_repo.sdk.profiles.config_file.read_profiles(*, config_dir=None)

Every saved profile, keyed by name. A missing file reads back as empty — there is nothing to migrate from, this is a brand-new mechanism.

synology_apm_repo.sdk.profiles.config_file.write_profiles(profiles, *, config_dir=None)

Overwrite profiles.json with exactly profiles, atomically — a crash mid-write must never leave a truncated file behind, since every profile lookup depends on this one file surviving intact.