config_store
Loading, saving and resolving the YAML configuration.
Installed applications are stored as references plus overrides: the record
names the store and the store app id, and overrides holds only the fields
the administrator changed. resolve_app merges the processed store entry
with those overrides to produce the InstalledApp the rest
of the server works with. Store updates therefore apply automatically after
every cache refresh, and the file stays small enough to edit by hand.
attributelogger= logging.getLogger(__name__)attributeSAFE_NAME_RE= re.compile('^[A-Za-z0-9 _.-]+$')attributeSTORE_ENTRY_FIELDStuple[str, ...]= ('name', 'logo', 'url', 'provider', 'provider_config')attributeLEGACY_TEMPLATE_KEYS= {'SELKIES_IS_MANUAL_RESOLUTION_MODE': 'SELKIES_MANUAL_RESOLUTION', 'SELKIES_H264_CRF': 'SELKIES_VIDEO_CRF', 'SELKIES_H264_FULLCOLOR': 'SELKIES_VIDEO_FULLCOLOR', 'SELKIES_H264_STREAMING_MODE': 'SELKIES_VIDEO_STREAMING_MODE', 'SELKIES_H264_PAINTOVER_CRF': 'SELKIES_VIDEO_PAINTOVER_CRF', 'SELKIES_H264_PAINTOVER_BURST_FRAMES': 'SELKIES_VIDEO_PAINTOVER_BURST_FRAMES'}attributeLEGACY_CLIPBOARD_KEYS= ('SELKIES_CLIPBOARD_ENABLED', 'SELKIES_CLIPBOARD_IN_ENABLED', 'SELKIES_CLIPBOARD_OUT_ENABLED')attributeLEGACY_ENCODER_NAMES= {'x264enc': 'h264enc', 'x264enc-striped': 'h264enc-striped'}funcis_safe_name(name) -> boolTell whether a store or template name is safe to use in a file path.
paramnamestrName supplied by an administrator.
Returns
boolTrue when the name only contains letters, digits, spaces, _,
funcdeep_merge(base, overrides) -> dict[str, Any]Recursively merge overrides into a copy of base.
Dictionaries are merged key by key; lists and scalars in overrides
replace the base value.
parambasedict[str, Any]Base dictionary (not modified).
paramoverridesdict[str, Any]Values that win.
Returns
dictA new merged dictionary.
funcdiff_overrides(full, base) -> dict[str, Any]Return the subset of full that differs from base.
Nested dictionaries are compared recursively so an override only records the leaves that changed.
paramfulldict[str, Any]Complete desired values.
parambasedict[str, Any]Reference values (the store entry).
Returns
dictA dictionary suitable for InstalledAppRecord.overrides.
funcensure_config_dir() -> NoneCreate the configuration directories if they do not exist.
Returns
Nonefuncload_app_stores() -> NoneLoad app_stores.yml into state.app_stores.
A default store pointing at the LinuxServer catalogue is written when the file does not exist.
Returns
Nonefuncsave_app_stores_sync() -> NoneWrite state.app_stores to disk synchronously.
Returns
Nonefuncsave_app_stores() -> NoneWrite state.app_stores to disk.
Returns
Nonefuncget_store(store_name) -> AppStore | NoneReturn the configured store with the given name, if any.
paramstore_namestrReturns
app.models.AppStore | Nonefuncstore_cache_file(store_name) -> strReturn the cache file path of a store.
paramstore_namestrReturns
strfunc_extract_apps(data) -> list[dict[str, Any]]Return the app list from a parsed store document.
paramdataAnyReturns
list[dict[str, typing.Any]]func_read_cached_script_b64(store_name, app_id, suffix='') -> str | NoneReturn the cached autostart script of an app as base64, if present.
paramstore_namestrparamapp_idstrparamsuffixstr= ''Returns
str | Nonefuncprocess_store_content(content, store_name) -> list[dict[str, Any]]Parse a store document into the entries the clients and resolver use.
Cached autostart scripts are injected as base64 and nested extension lists are flattened, matching what the admin UI sends back at install time.
paramcontentstrRaw YAML text of the store.
paramstore_namestrStore name, used to locate the autostart cache.
Returns
listList of app dictionaries.
funcload_store_entries() -> NoneParse every cached store into state.store_entries.
Returns
Nonefuncget_store_entry(store_name, app_id) -> dict[str, Any] | NoneReturn the processed store entry for an app, if the store knows it.
paramstore_namestrparamapp_idstrReturns
dict[str, typing.Any] | Nonefunc_fetch_and_cache_app_store(store) -> NoneRefresh one store's cache file using ETag conditional requests.
paramstoreAppStoreReturns
Nonefuncrefresh_store_caches() -> NoneRefresh every configured store's cache and reload store entries.
Returns
Nonefuncfetch_store_apps(store_name, url, refresh) -> list[dict[str, Any]]Return the processed app list of a store, fetching it when needed.
paramstore_namestrStore name (validated by the caller).
paramurlstrStore URL.
paramrefreshboolIgnore the cache and fetch from url.
Returns
listProcessed app entries.
funcautostart_cache_path(app, suffix='') -> str | NoneReturn the cache file for an app's repository autostart script.
paramappInstalledApp | InstalledAppRecordInstalled app or record; source must name a configured store.
paramsuffixstr= ''"" for X11 or "-wayland".
Returns
str | NoneThe path, or None when the store is unknown.
func_fetch_and_cache_single_script(store_name, base_url, app_id, suffix='') -> NoneFetch one autostart script into the cache using ETag conditional requests.
paramstore_namestrparambase_urlstrparamapp_idstrparamsuffixstr= ''Returns
Nonefuncrefresh_autostart_caches() -> NoneFetch autostart scripts for every store app that declares one.
Returns
Nonefuncrefresh_autostart_for_app(app) -> NoneRefresh the cached autostart scripts of a single installed app.
paramappInstalledAppThe resolved installed app.
Returns
Nonefunc_store_base(record) -> dict[str, Any] | NoneReturn the store entry restricted to the fields an installed app derives.
paramrecordInstalledAppRecordReturns
dict[str, typing.Any] | Nonefuncresolve_app(record) -> InstalledApp | NoneCompute the effective installed app from a record.
paramrecordInstalledAppRecordReference plus overrides as stored on disk.
Returns
InstalledApp | NoneThe resolved InstalledApp, or None (logged) when the
funcrecord_from_app(app, existing=None) -> InstalledAppRecordConvert a full installed app into a reference-plus-overrides record.
paramappInstalledAppComplete app as received from the admin UI.
paramexistingInstalledAppRecord | None= NoneCurrent record of the same app, whose overrides are replaced.
Returns
app.models.InstalledAppRecordThe record to persist.
funcapply_partial_update(record, patch) -> InstalledAppRecordMerge a partial update into a record.
Record fields (users, groups, template, ...) are set directly; everything
else is deep-merged into overrides.
paramrecordInstalledAppRecordCurrent record.
parampatchdict[str, Any]Partial InstalledApp shaped dictionary.
Returns
app.models.InstalledAppRecordThe updated record (a new object).
func_migrate_legacy_record(raw) -> InstalledAppRecordConvert a pre-0.2 full snapshot into a reference-plus-overrides record.
paramrawdict[str, Any]Returns
app.models.InstalledAppRecordfuncload_installed_apps() -> NoneLoad installed_apps.yml into state.installed_records and resolve.
Legacy full-snapshot records are migrated once and the file rewritten. Invalid records are skipped with a log line instead of clearing the list.
Returns
Nonefuncresolve_all_apps() -> NoneRe-resolve every record into state.installed_apps.
Returns
Nonefunc_records_for_disk() -> list[dict[str, Any]]Serialise the records, dropping empty overrides for readability.
Returns
list[dict[str, typing.Any]]funcsave_installed_apps_sync() -> NoneWrite the installed app records synchronously.
Returns
Nonefuncsave_installed_apps() -> NoneWrite the installed app records to disk.
Returns
Nonefuncset_record(record) -> InstalledApp | NoneStore a record in memory and resolve it.
paramrecordInstalledAppRecordThe record to keep.
Returns
InstalledApp | NoneThe resolved app, or None if it could not be resolved (the record
funcremove_record(app_id) -> NoneForget an installed app.
paramapp_idstrReturns
Nonefunc_is_true(value) -> boolparamvalueAnyReturns
boolfuncmigrate_legacy_template_settings(template_settings) -> dict[str, Any]Return template_settings with pre-refresh Selkies keys translated.
Renamed keys move to their current name unless the current name is
already present. The three clipboard booleans collapse into the
SELKIES_ENABLE_CLIPBOARD policy (true, in, out or false), and
encoder spellings the current Selkies no longer lists are mapped onto
the encoders that serve them. Unknown keys pass through untouched.
paramtemplate_settingsdict[str, Any]Returns
dict[str, typing.Any]func_load_templates_from(directory, source) -> NoneLoad every YAML template in directory into state.
paramdirectorystrparamsourcestrReturns
Nonefuncload_app_templates() -> NoneLoad default and user templates into state.app_templates.
A blank Default template is created when none exist.
Returns
Nonefunctemplate_filename(name) -> strReturn the file name derived from a template name.
paramnamestrReturns
strfuncsave_app_template(template) -> NoneWrite a template to the user template directory and reload.
When a template of that name was loaded from a differently named file (for example after a hand edit) the existing file is reused so no orphan is left behind.
paramtemplateAppTemplateTemplate to save.
Returns
Nonefuncdelete_app_template(name) -> NoneDelete a user template by name.
paramnamestrTemplate name.
Returns
Nonefuncload_sessions() -> NoneLoad persisted sessions into state.sessions.
Returns
Nonefuncsave_sessions() -> NonePersist state.sessions to disk.
Returns
Nonefuncload_public_shares() -> NoneLoad public share metadata into state.public_shares.
Returns
Nonefuncsave_public_shares() -> NonePersist state.public_shares to disk.
Returns
None