wrolpi/wrolpi
lrnselfreliance ce7095c0a1
A config import records the version of the file it read (#897)
* A config import records the version of the file it read

Every Sanic process initializes the configs it shares with the others while one of them imports the
database configs.  `ConfigFile.initialize` reset the shared dict to the defaults (version 0) before
loading the file, and the import read the file's version from that shared dict.  When the two
overlapped, the import recorded version 0 in `config_version`; every later save of that config was
refused as older than its file, and the next startup's import undid the unsaved changes.

- `ConfigFile.initialize` sets the shared dict in one call, and `MultiFileConfig.initialize` no longer
  empties it first, so other processes never see the defaults in place of the file.
- An import reads the version and rows from the file it read (`import_file_config`), never the shared
  dict.

Tests run the race for every config.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Playlists import steps read the file's config; tests restore switch handlers

- `PlaylistsConfig._keep_unreadable_items` and `_merge_items` read `import_file_config`, not the
  shared `_config`.
- `test_import_steps_read_the_file`: no versioned config's `prepare`/`after_import` (or the methods
  they call) reads the shared config.
- The new tests create configs, which replaced the global configs' switch handlers for later tests
  (repos tests then dumped a test's config).  `restore_switch_handlers` puts them back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Only the first process loads a shared config; the others attach

A restarted perpetual process initializes the configs while the other processes serve them.
Re-loading the files then reverted or dropped newer changes in the shared dict (an inventory
created or saved since, a config updated but not saved yet).

- `ConfigFile.initialize` loads the file only into an empty shared dict, under
  `config_update_lock`; otherwise it keeps what the dict holds.
- `MultiFileConfig.initialize` imports only into an empty shared store, under `save_lock()`, and
  points `_configs` back at the shared store if the import fails.
- `MultiFileConfig.create` checks for the slug and inserts it under `save_lock()`.

`test_initialize_keeps_the_shared_config` now changes the shared config between two processes'
initializes (an inventory renamed and another created), and requires the second to keep it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 21:03:52 -06:00
..
blobs zim: ship a default fallback Zim and honor the configured Zim directory 2026-07-20 19:09:57 -06:00
collections A config import records the version of the file it read (#897) 2026-10-27 21:03:52 -06:00
files A config import records the version of the file it read (#897) 2026-10-27 21:03:52 -06:00
scripts zim: address PR review — config race, YAML null, path traversal, pinned build 2026-07-20 19:10:09 -06:00
static/extensions Bump extension to v0.2.4 2026-06-01 19:23:39 -06:00
test A config import records the version of the file it read (#897) 2026-10-27 21:03:52 -06:00
__init__.py Removing WROLPi admin functionality that is now in Controller. 2025-12-19 18:41:27 -07:00
api_utils.py API JSON: encode paths without a lookup per path (#810) 2026-10-09 19:45:43 -06:00
bookmarks.py Configs without database rows read and validate only; imports run off the event loop (#874) 2026-10-25 15:17:31 -06:00
bookmarks_api.py Bookmarks: a nav menu of user links, stored in bookmarks.yaml (#729) 2026-09-26 13:11:36 -06:00
captions.py videos: address review — atomic caption write + strict YouTube host gate 2026-07-16 18:51:51 -06:00
cmd.py Remove unused code found by vulture (#885) 2026-10-27 15:50:09 -06:00
common.py A config import records the version of the file it read (#897) 2026-10-27 21:03:52 -06:00
config_api.py A malformed entry stops a backup preview or merge with an error naming it (#896) 2026-10-27 20:59:49 -06:00
config_import.py A malformed config entry is skipped and counted instead of failing the import (#875) 2026-10-25 16:28:34 -06:00
config_schema.py Remove unused code found by vulture (#885) 2026-10-27 15:50:09 -06:00
config_version.py Configs without database rows read and validate only; imports run off the event loop (#874) 2026-10-25 15:17:31 -06:00
conftest.py A config import records the version of the file it read (#897) 2026-10-27 21:03:52 -06:00
contexts.py Keep playlists.yaml in shared memory so the perpetual process can save it (#881) 2026-10-25 19:57:29 -06:00
dates.py Remove code that only tests called (#888) 2026-10-27 16:00:27 -06:00
db.py Remove unused code found by vulture (#885) 2026-10-27 15:50:09 -06:00
db_bootstrap.py A library on the internal disk gets a database (#832) 2026-10-14 16:15:33 -06:00
db_query.py Database schema lists each column's foreign key (#822) 2026-10-11 19:38:39 -06:00
downloader.py A malformed entry stops a backup preview or merge with an error naming it (#896) 2026-10-27 20:59:49 -06:00
errors.py Remove unused code found by vulture (#885) 2026-10-27 15:50:09 -06:00
events.py Remove unused code found by vulture (#885) 2026-10-27 15:50:09 -06:00
flags.py A library on the internal disk gets a database (#832) 2026-10-14 16:15:33 -06:00
fts.py Remove unused code found by vulture (#885) 2026-10-27 15:50:09 -06:00
jobs.py api: run the perpetual loops in one Sanic-managed process (#718) 2026-09-23 07:53:53 -06:00
lang.py Including Country/Region codes in caption file names. 2024-10-16 18:56:31 -06:00
log_levels.py Reworking and unifying log levels. 2025-12-16 19:20:04 -07:00
logging_extra.py Not throwing error when checking for empty message. 2026-06-28 13:23:42 -06:00
media_path.py Upgrade to SQLAlchemy 2.0 (synchronous) (#803) 2026-10-09 15:08:40 -06:00
perpetual.py perpetual: clear in-progress flags after a crash, downloads only in the perpetual process, KillMode=mixed (#726) 2026-09-26 11:22:58 -06:00
roland@learningselfreliance.com.gpg Updating git signing gpg key. 2024-10-16 18:57:06 -06:00
root_api.py A recurring Download with more than one URL is an error (#887) 2026-10-27 15:57:47 -06:00
schema.py Remove unused code found by vulture (#885) 2026-10-27 15:50:09 -06:00
schema_ddl.py Upgrade to SQLAlchemy 2.0 (synchronous) (#803) 2026-10-09 15:08:40 -06:00
scrape_downloader.py Scrape: fix multiple suffixes and relative link resolution (#801) 2026-10-08 20:05:59 -06:00
speedtest.py Speed Test calculator: ping, download, and upload against the API (#708) 2026-09-13 18:47:18 -06:00
switches.py Fix API stalls: non-blocking switch worker, threaded searches, indexed Videos page (#678) 2026-08-29 16:17:53 -06:00
tags.py A malformed entry stops a backup preview or merge with an error naming it (#896) 2026-10-27 20:59:49 -06:00
test_media_path.py Add Docs module for searching and organizing PDFs and EPUBs 2026-03-20 14:17:06 -06:00
upgrade.py api: run the perpetual loops in one Sanic-managed process (#718) 2026-09-23 07:53:53 -06:00
vars.py Remove unused code found by vulture (#885) 2026-10-27 15:50:09 -06:00
version.py upgrade: report git branch via --show-current so a stale release tag can't break upgrades 2026-07-29 16:03:33 -06:00
version.txt Bump version to 0.30.1-beta 2026-10-15 19:57:29 -06:00