The kiwix naming scheme is {name}_{YYYY-MM}.zim, and a re-release in the same
month carries a letter: 3dprinting.stackexchange.com_en_all_2026-07a.zim.
parse_name rejected the letter, so such a Zim was never checked for newer
releases and zims.yaml keyed it by its full stem instead of its name. The
letter is now accepted and folded into the day of the month-precision date, so
a re-release orders after the plain release wherever dates are compared. The
pattern also anchors the ".zim" extension instead of matching any character.
A Zim that is not kiwix-named (edibleplantdb.zim) has no date to compare and is
simply not checked. find_outdated_zim_files logged that at WARNING for every
such file at every start; it is a DEBUG line now.
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
* A refresh that finishes before tags.yaml is imported no longer reports a failed save (#941)
Every refresh fires save_tags_config at its cleanup. In the first seconds
after a start, a refresh can finish before the startup import of tags.yaml,
which on a rebuilt database happens while the first refresh runs. The dump
then asked ConfigFile.save to write a database that held no tags over the
file; the save guard refused, as it must, but it did so with an ERROR traceback
and a "Failed to save config: config/tags.yaml" event for the user, although
nothing was lost: the import that followed read the file and recreated the tags.
save_tags_config now skips the dump while the config has not been imported and
says so at WARNING. The file stays the source of truth until the import.
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
* Removing a duplicate video keeps the Download that is finishing
After a video download, Video.delete_duplicate_videos removes the other copies
of the same video, which happens when the file name changed (a renamed file, a
new title). Each copy was deleted through FileGroup.delete, which also deletes
the Download of the copy's URL and, without one, adds the URL to the skip list.
The duplicates share that URL with the video just downloaded, so the Download
still running was deleted from under its worker: the worker read its row again
to record the result and failed with NoResultFound ("Unexpected error"), and the
download's record was gone.
FileGroup.delete and Video.delete take keep_download; the duplicate cleanup
passes it, so the URL's Download and the skip list are left alone.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Only a duplicate at the downloaded URL keeps its Download
delete_duplicate_videos also finds copies by source_id, and those can sit under
another URL. Such a copy is deleted as any video is, with that URL's Download
or a skip-list entry; only a copy that shares the URL being downloaded leaves
the finishing Download alone.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Every refresh fires save_tags_config at its cleanup. In the first seconds
after a start, a refresh can finish before the startup import of tags.yaml,
which on a rebuilt database happens while the first refresh runs. The dump
then asked ConfigFile.save to write a database that held no tags over the
file; the save guard refused, as it must, but it did so with an ERROR traceback
and a "Failed to save config: config/tags.yaml" event for the user, although
nothing was lost: the import that followed read the file and recreated the tags.
save_tags_config now skips the dump while the config has not been imported and
says so at WARNING. The file stays the source of truth until the import.
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
retry_downloads_on_startup set pending, deferred and failed Downloads back to
"new". A failed once-download has already given up: its downloader raised
UnrecoverableDownloadError or it reached its attempt limit. Renewed at every
boot, it only failed again at once and logged a traceback-level warning each
time. Startup now renews only the pending and deferred Downloads, which were
interrupted or are waiting for their next try. The user's Retry button still
renews failed Downloads and resets their attempts.
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
GET /api/zim went through Zims.get_all, which opened every Zim's Archive in the
API process, and then Zim.__json__ opened each one again for its metadata.
python-libzim holds the GIL and a cold open of a large Zim takes seconds, so
loading the Zims page stalled that API worker for every other request (27.8 s
cold against 0.75 s warm for 44 Zims). #928 moved estimates and searches to the
worker process; the list now uses the same worker for metadata, and a Zim the
worker cannot read is left out as before. count_tagged_zim_entries shares the
new readable_zims helper. Zims.get_all had no other callers and is removed.
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
After a download, ffmpeg decodes the last 30 seconds of the video and any stderr
line not on the ignore list marks the video incomplete. Seeking into an h264
stream can make the decoder print "mmco: unref short failure": a note about
reference-picture marking for frames before the seek point. The frames decode
and ffmpeg exits 0, but the verdict was "Video was incomplete", so the download
was deferred and the same sound video was downloaded again on every retry.
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Setting a config field calls ConfigFile.update(), which takes
api_app.shared_ctx.config_update_lock. The test did not use async_client,
so the lock only existed when another test in the same process had already
attached the shared context; running first in a worker, it failed with
"'SharedContext' object has no attribute 'config_update_lock'".
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
MultiFileConfig.initialize() imports every file while holding the shared save
lock, which is not reentrant. The repair added in #901 took that lock again from
inside import_all, so any WROLPi whose inventory still held epoch-second dates
hung every API process at startup.
The repair now only rewrites the in-memory entities during import and records
which inventories changed. import_inventories_config() writes those files once
it runs, outside the lock. A regression test runs initialize() against an
epoch-date file with a timeout.
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
A rebuilt database imports zims.yaml before the refresh has modeled a single
Zim. That import has no database version to compare with, so it saves the
config afterward, and the save wrote only the Zims in the database: none. The
file's choices were erased and every Zim was then modeled with the default.
The dump now starts from the file's entries and overlays the database's, so a
choice survives until its Zim is modeled again, and a Zim in the database still
decides its own line.
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Doc._hide_calibre_files opened a second write session while the modeler held
the item's transaction. SQLite has one writer, so the second session waited
out the 30 s busy timeout and failed with "database is locked"; the modeler
retried three times, so every Calibre epub cost about 98 s and stayed
unmodeled, and the cover.jpg / metadata.opf FileGroups it should have deleted
survived. On a library of 1663 Calibre books the global refresh's modeling
phase would have taken about two days.
The nested session dates from before the SQLite cutover, when Postgres row
locks let it work. The delete now runs in the caller's session.
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
* Map downloads are checked against the hash in the signed manifest
A meta4 signs only a bare hash, so any genuinely signed meta4 (an older version of a region, another region) passed
its own check. The manifest now lists each file's sha256; it is signed as a whole, so the hash is tied to the URL.
The catalog copies each hash into its download's settings, and aria2c checks the file against it. Downloads from a
manifest without hashes still require the file's signed meta4.
build_map_regions.py writes the hashes, and hash_map_manifest.py adds them to the published manifest from the
verified meta4s without rebuilding any maps.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* hash_map_manifest.py hashes each file's bytes instead of trusting its meta4's name
Only the bare hash in a meta4 is signed, so an older version's meta4 with its name rewritten (or terrain's, whose name
never changes) passed the name and duplicate-hash checks. Each file is now hashed from a local copy of the published
files (--files) or downloaded from the CDN, and must match its signed meta4.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
_upsert_files deleted the FileGroup of every companion file before
inserting, so a FileGroup whose primary file became a companion (foo.jpg,
then foo.mp4 arrives) was replaced by a new, untagged row. A FileGroup
whose primary file was replaced (foo.txt deleted, foo.mp4 added) still owned
the (directory, stem), and the INSERT failed on the unique index.
Before inserting, the FileGroup owning each incoming (directory, stem) is
renamed to the new primary path, keeping its id, tags, collection
membership, model and viewing state. When a different FileGroup owns the
primary path, the two collapse into the one dedupe prefers (modeled, then
tagged). A companion's leftover FileGroup gives its tags, collection
membership and viewing state to its group's FileGroup before it is deleted.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The toggle was only the zim.auto_search column, which defaults to on. The
database is rebuilt from files and configs, and a Zim's newer version is a new
row, so every rebuild and every subscription update turned search back on for
every Zim. On a large library the global search then searched all of them.
zims.yaml records auto_search for each Zim, keyed by the Zim's name without
its date, so a newer version of a Zim is the same Zim. A Zim the file does not
name is searched (the default stays on). The config is imported on startup
with the usual version gating, saved when the toggle changes, and a newly
modeled Zim takes its setting from it.
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
_upsert_files kept a FileGroup's files and indexed state when the size,
newest modification time and number of files were unchanged. A file that
replaced another (foo.png for foo.jpg, same size, older than foo.mp4) left the
old file in `files` and the FileGroup indexed.
The upsert now compares the sorted file names. FileGroups that still store
absolute paths (the old format) compare by name too, so they are not
re-indexed when nothing changed.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Map files are never downloaded without a signed hash
A region, terrain, or search index download whose .meta4 is missing or unfetchable now fails (and retries later)
instead of downloading with TLS as its only check. The search index downloader had no fallback branch at all, so it
downloaded with no hash whenever the .meta4 was missing.
A real aria2c test pins what this relies on: aria2c refuses a file that does not match the signed hash, even when
the meta4's unsigned name differs from the URL.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* aria2c checks map files only against the signed hash, and a rejected file is never kept
Only the sha-256 hash in a meta4 is signed, but aria2c was given the whole downloaded meta4. A sha-512 of a tampered
file added beside the signed sha-256 made aria2c accept the tampered file. aria2c now gets a meta4 built from the
signed hash and the download URL alone.
A rejected download was left in the map directory under its final name, where the next attempt took it as already
downloaded. Map files now download into map/.partial and move into place only once aria2c accepts them; a file that
fails the hash check is deleted so a retry starts over, other failures keep it so the download resumes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Only the map file aria2c checked is moved into place
download_file reports the path named by the server's HEAD response (Content-Disposition, redirects), while aria2c
saves and checks the file under the name in the meta4 WROLPi writes. When they differed, an unchecked file (such as
an interrupted download's leftover in map/.partial) could be moved into place. The meta4 name now comes from the
URL, must be a plain file name, and any other reported path fails the download.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Zim search estimates run in a separate process so a cold estimate cannot stall the API worker
The global search estimates every auto-search Zim on each keystroke. On a
large library that estimate took tens of seconds when the Zims' pages were not
cached, and every other request routed to the same Sanic worker, such as the
channel suggestions, waited behind it. Two things held the worker: opening a
large Zim cold takes seconds (ten for a 75 GB Zim) and `Zims.get_all` did that
on the event loop; and python-libzim never releases the GIL, so the estimate
offloaded with asyncio.to_thread still froze the worker.
Everything libzim does for an estimate now runs in a standalone script started
as a subprocess (Sanic workers are daemonic, so a multiprocessing pool cannot
be forked from them). It reads the Zim paths and search string on stdin and
writes the counts on stdout. A Zim it cannot read is reported and left out, as
`Zims.get_all` would leave it out.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Zim searches run in the libzim worker process too
The /api/zim/search endpoints had the same stall as the estimate: they opened
every Zim through Zims.get_all and searched them with libzim, which holds the
GIL, so a thread offload still froze the Sanic worker.
The estimate script is now a general libzim worker with estimate, search and
entries jobs. A search of all Zims sends every Zim's job to one worker
process; the API worker only headlines the returned HTML and looks up tags.
The worker also returns each Zim's metadata so Zim.__json__ does not open the
Zim again on the event loop. Zim.entries_with_tags is split so the tagged
paths come from the database without opening the Zim.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Tagged Zim estimates count from the database, and a cancelled request kills the libzim worker
Review of the earlier commits found two gaps. Estimates with tags selected
still went through Zims.entries_with_tags, which opened every Zim in the API
process, and after the thread offload was removed it did so on the event loop;
they now count the tagged paths in SQL and ask the worker only for metadata.
And Sanic cancels a handler at its response timeout or on disconnect, which
left the worker process running until its stdout pipe filled; the runner now
kills and reaps it on cancellation.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
group_files_by_stem and chunks_by_stem assumed a stem's files are adjacent
once sorted. They are not: foo.f137.mp4 (stem foo.f137) sorts between
foo.en.vtt and foo.mp4 (stem foo), and foo.tar.gz between foo.jpg and
foo.txt. _upsert_files then built two FileGroups for one (directory, stem)
and the refresh failed with "UNIQUE constraint failed: file_group.directory,
file_group.stem". A chunk boundary could split a stem the same way.
Both helpers now group by (directory, stem).
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Python packages install from hash-locked requirements; yt-dlp still floats
Every pip install trusted PyPI over TLS: requirements.txt pins only top-level versions
(some with >=), the controller's are almost all >=, and dependencies were never pinned, so
a forged certificate (as the eMudhra key compromise allowed) could change code in the API,
the controller, or the archive container. scripts/lock_requirements.sh generates a
universal, hash-locked .lock beside each requirements.txt, and
install_python_requirements.sh installs it with --require-hashes at every site. yt-dlp is
left out of the lock and upgraded afterwards so devices still get YouTube fixes; its
dependencies are locked. The unpinned `pip install --upgrade pip` steps are gone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The unhashed yt-dlp install cannot replace locked packages, and nothing builds from source
Review of #913 found two holes. The yt-dlp step ran without --no-deps, so pip's
only-if-needed strategy would still fetch an unhashed dependency whenever yt-dlp's metadata
asked for a version the lock did not install. And srt is published only as a source
archive, whose build installed setuptools with hash checking off on every install.
The yt-dlp step now uses --no-deps (its dependencies come only from the lock), both steps
are retried as the image builds did before, and installs and locks are wheels-only. srt
3.5.3 is vendored unmodified as wrolpi/vendor/srt.py (MIT), verified against the sdist
hash the lock pinned; webvtt-py's SRT reader rejects WROLPi's own test file, so it is not
a replacement.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Legacy inventory items stored date fields as Unix epoch seconds. The table showed the raw numbers, and sorting and expired highlighting did not treat them as dates.
- Frontend parses date values as YYYY-MM-DD or legacy epoch seconds; display, mobile view, export, search, sort and the expired check all use calendar dates with no timezone shift.
- The legacy migration converts epoch seconds to YYYY-MM-DD, and import repairs already-migrated files once.
- Jest runs with a pinned timezone; the expiry tests pass under any process timezone.
Closes#41
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
They were installed with `npm i -g`, which pinned only the three top-level versions and
resolved their 156 dependencies fresh from the registry, so a forged TLS certificate (as
the eMudhra key compromise allowed) could change code WROLPi runs on every archive.
npm-tools/package-lock.json pins every package with its sha512, and install_npm_tools.sh
runs `npm ci` and links the commands into /usr/local/bin for every install path, upgrades,
both images and the archive container. The app container's unpinned, unused global serve
is removed.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The install scripts, the nginx-to-Caddy upgrade, and the Pi image downloaded Caddy's apt
signing key and source list over TLS and trusted them as-is, so a forged certificate could
serve a key that signs other caddy packages. add_caddy_apt_repo.sh installs the key the
ISO already uses (fingerprint 65760C51EDEA2017CEA2CA15155B6D79CA56EA34) as an armored
keyring and names it in the source's signed-by.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* An upgrade refuses to roll back to an older commit of the current branch
upgrade.sh verifies the fetched commit's signature, but a signature proves a commit is
WROLPi's, not that it is the newest; an intercepted fetch could serve an old signed
release and the forced checkout would roll the device back to it. refuse_rollback stops
when the target is an older commit of the branch the device is on (a detached HEAD from a
release image counts as that branch). Branch switches, the same commit, and history the
device does not contain (Debian 12 devices on debian12-final) are allowed, and -d allows
a deliberate downgrade; it reaches the upgrade service through the env file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* An upgrade also refuses a signed commit with a lower version from other history
Ancestry alone only caught older commits in the device's own history; any other signed
commit, such as debian12-final or an old experimental branch, passed. refuse_rollback
now also compares wrolpi/version.txt, which is inside the signed tree, and refuses a lower
or missing version. A force-pushed branch at the same or a higher version still upgrades.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Tests pin the two parts of refuse_rollback that only one rule catches
An earlier commit of the same version is refused only by the ancestry check, and
0.30.10-beta after 0.30.3-beta only orders correctly with sort -V; the fixture's
single-digit versions passed with either part removed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Only upgrade.sh checked the release key's signature. install.sh and the Pi and ISO
builds cloned by branch or tag name and ran what GitHub returned, so a forged TLS
certificate (as the eMudhra key compromise allowed) could change what a fresh install
or a published image runs. verify_wrolpi_commit.sh requires a VALIDSIG from the pinned
release-key fingerprint. The image builds verify their clone with the verifier and key
from the build checkout; install.sh carries an identical copy of the function, since it
runs before any verified checkout exists.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
upgrade.sh downloaded Deno on every device whose Deno was older than the pinned
version and installed it without a check, so a forged TLS certificate (as the eMudhra
key compromise allowed) could replace the runtime yt-dlp uses. The zip is now checked
against the same sha256 the install scripts pin; a mismatch skips the Deno install and
the upgrade continues. A test requires every Deno download in the repo to be checked.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The Pi build downloaded pi-gen's `arm64` branch head as a zip and ran it as root, and
downloaded Deno without checking it, so a forged TLS certificate (as the eMudhra key
compromise allowed) could change what went into the image. pi-gen is now fetched by
commit hash, which git verifies against the objects, and the Deno zip is checked
against the same sha256 the other installers pin.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The Job replaces the video file (and its ffprobe json), so the sums in the info json's
wrolpi section described files that were gone. Once the refresh has re-modeled the
Video, its files are hashed again, without a session held, and the sums replaced.
A Video without recorded sums gains none.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
apply_modelers and apply_indexers count `file_group WHERE indexed != 1` for progress
and apply_indexers selects its batches with it. SQLite cannot use an index for `!=`,
so each of these read every file_group row; on a large library with a cold disk cache
the first count took close to a minute. A partial index holds only the unindexed rows.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* A download records the sha256 of its files in the wrolpi section
A video download writes `wrolpi.sha256` into its .info.json; an archive download writes it into
its .readability.json. Sums are keyed by suffix, so a rename or Reorganize keeps them valid,
and the metadata JSON holding them is not hashed.
Large files are hashed in execute_download (in a thread, without the DB session). Finalize
reuses those sums while a file's mtime is unchanged and hashes only files finalize created or
changed (a converted poster, the ffprobe json).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A video download hashes only for an info json, and finalize never suspends
Finalize holds the write session; awaiting the hash let the loop run a switch whose
write waited on that session, stalling the loop for the busy timeout. Finalize now
hashes inline: the large files were hashed in execute_download.
A download that writes no info json has nowhere to keep the sums, so it no longer
reads its files to hash them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
lib.delete() ran the modelers, indexers, and refresh cleanup inline. Those cover the
whole library (any unmodeled or unindexed FileGroup anywhere), so a single-file delete
waited on unrelated work and could exceed the response timeout. The deleted FileGroups
are still removed before the delete returns; the post-processing now runs in the
FileWorker through a queued refresh of the same paths.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The lookup compared SQLite's lower(name), which folds only ASCII, with Python's
str.lower(), which folds Unicode. "Édouard Hospitalier" never matched its own
collection, so the doc modeler inserted a duplicate, hit the unique constraint, and
re-extracted and failed on that doc on every modeler run. Both sides now use
SQLite's lower().
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Uploads, deletes, and file refreshes looked up a missing path's descendants with
`directory LIKE 'path/%'`. SQLite cannot use an index for that LIKE, so each lookup
scanned the whole file_group table; with a cold page cache on a large library this
held the first upload chunk or a delete for tens of seconds. LIKE also treated `_`
and `%` in a path as wildcards, so refreshing a missing `a_b` removed the FileGroups of
an existing `aXb/sub`.
`directory_or_descendant` matches with a range the directory index can serve.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* The Internet check is configurable and no longer stalls background work
The check connected to one host (one.one.one.one, port 80) with no timeout, in
the perpetual process's event loop. On a network that drops traffic to that
host, each attempt hung for about two minutes and froze every other perpetual
loop (config saves, downloads, the file worker, the media mount check), so
WROLPi reported "No Internet" and "No drive mounted" though both were fine.
- wrolpi.yaml's internet_check_hostname (default one.one.one.one, needs DNS) and
internet_check_ip (default 1.1.1.1) choose what to connect to; the Internet is
up when either answers. Either may be empty. The INTERNET_SERVER environment
variable is gone.
- A connection gives up after 5 seconds.
- The check runs in a thread.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* The Internet check tries its IP address first
socket.create_connection resolves a hostname before its timeout applies, so a
name lookup that hangs (a firewall dropping DNS) postponed the IP address, which
needs no lookup.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
channels.yaml saves only a Channel's recurring Downloads (Channel.downloads), but
its import compared every Download of a Channel's Collection. A once-Download of
a Channel's video was "removed from the file", so an import with deletes deleted
it, even one that had not run yet. The import now compares, and deletes, only
recurring Downloads.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* 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>
* A malformed entry stops a backup preview or merge with an error naming it
Backup previews and merges read every config entry as well-formed: a malformed one (an entry that is not a
mapping, a missing or non-text identity, a short tag_files line) raised an AttributeError or TypeError, so the
preview was a 500 and a merge failed with a generic message. `ConfigFile.backup_entries` now checks each entry
a preview or merge reads, in the backup and in the current config, and raises InvalidConfig naming the file and
the entry; the merge endpoint passes that message on. A malformed entry may be corrupt, so it is not skipped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* A falsy "tags" that is not a mapping is an error in a backup preview or merge
`tags: []`, `''`, `0` or `false` became no tags through `or dict()` before the mapping check. Only a missing
or null `tags` means no tags now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
A configured browser_executable was used without checking it exists. A config on the media drive can outlive the
OS it was written on: Raspberry Pi OS's /usr/bin/chromium-browser is /usr/bin/chromium on Debian. The wrapper
discards the browser's stderr, so its failed exec only showed as single-file's "Connection refused ... Child
process has already terminated", and every archive failed. Now a missing configured browser is logged and one is
detected, as when none is configured.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>