wrolpi/app/src/components
lrnselfreliance 6cd233dce6
Sync and backup: a secondary WROLPi and a backup drive copy the library (#957)
* A secondary WROLPi copies its primary's library over HTTP

A WROLPi with role "secondary" pulls from its primary: a manifest of every
FileGroup's files (/api/sync/manifest), then each missing or changed file
from the primary's Caddy /media/ (resumable, written to a hidden partial and
renamed with the primary's mtime), a refresh, then the library configs,
imported as the primary wrote them.  wrolpi.yaml contributes only its library
settings.  Files deleted on the primary are kept.

A secondary never saves the synced configs and never downloads.  Its API
answers 503 SYNCING while a sync runs, and every page warns that it is a
copy.  It syncs in a daily window or on "Sync now"; WROL Mode stops it.

On a Pi 4 (no AES instructions) the client uses TLS 1.2 ChaCha20, which
pulls ~110 MB/s from Caddy versus ~41 MB/s for rsync over ssh.

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

* Sync has its own /admin tab; a sync's reads from the primary are bounded

The sync settings and progress move from Settings (and the component
gallery, which is for library components) to /admin/sync.

A download never writes past the size in the primary's manifest, and configs,
listings, and manifest pages are capped.  A primary address may not carry a
user name or password (it is logged and shown).  While a sync runs, the API
answers only the exact requests that show its progress or stop it.

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

* A sync keeps the secondary's replaced configs in today's config backup

The first copy of the day is kept, like a save, so a config backup import
undoes a sync's config changes.

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

* Docker's Caddy logs every request

`docker compose logs -f web` shows each request with its status, size and
duration, e.g. a secondary's /media/ downloads during a sync.

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

* A sync reports its progress as it downloads, and refuses quietly

The status updated only when a page of 500 FileGroups finished, so a page of
large files looked stuck; it now updates every 2 seconds.  Requests refused
while syncing are answered by the middleware instead of raised, so the UI's
polling no longer logs an error each time.  The primary's version is stored
without its trailing newline.

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

* A WROLPi can back up to a second drive; sync settings live in sync.yaml

The Sync tab's Backup Drive copies the media directory to a second mounted
drive with rsync during the sync window (hourly), or on "Back Up Now".
Nothing on the backup drive is deleted.  The Tags and playlists directories
are left out (WROLPi rebuilds them from the configs), and the database is
written as an SQLite snapshot rather than copied as files, so the drive can be
mounted as the media directory and start.  A backup is written only while the
chosen drive (by UUID) is mounted where it was chosen, and is not the media or
system drive; rsync is stopped if the drive disappears.  Not in Docker, which
cannot reach other drives.

Role, primary, window and backup drive move from wrolpi.yaml to sync.yaml:
they belong to this machine, and are never copied from a primary.

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

* The Sync tab shows the configured backup drive

getSettings copies each setting by name and did not list the backup drive,
so the Sync tab showed "None" while one was configured.  It also dropped
`version`.  A test now fails for any setting the API sends that getSettings
drops.

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

* A backup can go to a folder on its drive, and remembers its last success

The Backup Drive panel takes a folder on the chosen drive.  The drive is
checked through the folder's mount point: the folder is written only when the
drive with the saved UUID is mounted there, so a folder left on the system
drive by an unplugged drive, or on another drive mounted inside the chosen
one, is refused.  A missing folder is created once the drive is checked.

When the last backup succeeded is saved in sync.yaml, so it is known after a
restart.  "Stop Backup" is disabled while the database snapshot is written (it
runs to the end), and a finished backup clears the request to stop.

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

* The backup drive has its own window

The sync window was shown in the Sync panel but also scheduled the backup
drive.  The Backup Drive panel now has its own window (sync.yaml
backup_window_start/end), saved with the drive; the sync window is shown,
and used, only for a secondary's sync.

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

* Sync and the backup drive can each exclude folders

A secondary or a backup drive may be smaller than the primary's library.
Each Sync tab panel has its own excluded folders in sync.yaml, chosen in
a folder browser: a secondary browses its primary's folders (through
Caddy), the backup drive browses this WROLPi's media directory.  Excluded
folders are never copied; what was copied before is kept.

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

* The folder browser does not offer lost+found

Every ext4 drive has a root-only lost+found folder; a sync and a backup
never copy it, so it is not offered for exclusion.

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

* A sync never writes into config or tags, whatever their case

On a media drive that ignores case (exFAT, NTFS, macOS), a manifest path
like Config/wrolpi.db is the real config folder. The protected and
unlisted top-level folders are now compared case-insensitively in the
manifest, in resolve_destination, in excluded-folder validation, and in
both folder listings.

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

* A backup writes the database snapshot only when the database changed

Every backup rewrote the whole database snapshot (2.5 GB on a busy
WROLPi), even on the window's idle hourly runs. The snapshot is now
skipped when the live database (its size and mtime, and those of a
non-empty WAL) and the drive's copy are both unchanged since the last
snapshot. The record is in memory, so the first backup after a restart
writes it.

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

* Remove the unused save_sync_config switch

Nothing activated it; SyncConfig saves directly.  The test server's
log_message override is called by http.server, so it goes in the
vulture baseline.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 10:53:45 -07:00
..
admin Sync and backup: a secondary WROLPi and a backup drive copy the library (#957) 2026-11-11 10:53:45 -07:00
calculators Add a Solar calculator (#778) 2026-10-04 18:36:45 -06:00
collections Add a Repos module that mirrors git repositories (#783) 2026-10-07 15:16:58 -06:00
inventory Format inventory expiration dates instead of epoch timestamps (#901) 2026-10-31 12:27:21 -06:00
ui The Settings upgrade can switch to a chosen branch (#954) 2026-11-08 08:49:26 -07:00
AddToPlaylist.js ui: Common.js and thirteen more files off Semantic 2026-08-08 18:04:00 -06:00
Apps.js app: Flasher saved configs and Statistics distinguish pending from empty (#733) 2026-09-26 17:05:02 -06:00
Archive.js ui: the last of Semantic UI, in name and in dead CSS 2026-08-08 18:05:54 -06:00
ArchivePreview.js ui: Common.js and thirteen more files off Semantic 2026-08-08 18:04:00 -06:00
Bookmarks.js Bookmarks: a nav menu of user links, stored in bookmarks.yaml (#729) 2026-09-26 13:11:36 -06:00
Bookmarks.test.js Bookmarks: a nav menu of user links, stored in bookmarks.yaml (#729) 2026-09-26 13:11:36 -06:00
BulkTagModal.js ui: only the top modal answers Escape, and the audited widths 2026-08-08 18:05:49 -06:00
BulkTagModal.test.js ui: migrate Downloads, Upload, and BulkTagModal off Semantic 2026-08-08 18:04:02 -06:00
Calculators.js Add a Solar calculator (#778) 2026-10-04 18:36:45 -06:00
CbzViewer.js Resume EPUBs and comic books where the reader left off (#798) 2026-10-08 18:19:51 -06:00
CbzViewer.test.js Resume EPUBs and comic books where the reader left off (#798) 2026-10-08 18:19:51 -06:00
Channels.cy.js Remove CircleCI (#796) 2026-10-08 17:19:38 -06:00
Channels.js ui: a Back button is a row of one, not a stretched flex child 2026-08-08 18:05:52 -06:00
CodecSettings.test.js videos: codec download preferences with transcode and strict-fail options (#701) 2026-09-07 09:12:00 -06:00
Common.js Resume videos and audio where the user left off; show progress on cards (#791) 2026-10-08 17:29:22 -06:00
Common.test.js Add a Repos module that mirrors git repositories (#783) 2026-10-07 15:16:58 -06:00
DatesSelector.js ui: thirty-five files off Semantic, leaving fifteen 2026-08-08 18:04:01 -06:00
DesktopToggle.test.js ui: Common.js and thirteen more files off Semantic 2026-08-08 18:04:00 -06:00
Docs.js Resume EPUBs and comic books where the reader left off (#798) 2026-10-08 18:19:51 -06:00
Docs.test.js Resume EPUBs and comic books where the reader left off (#798) 2026-10-08 18:19:51 -06:00
DomainEditPage.test.js ui: the last of Semantic UI, in name and in dead CSS 2026-08-08 18:05:54 -06:00
DomainsPage.test.js Reformatting code. 2025-12-06 15:11:37 -07:00
DomainTagging.test.js test: one place for fixtures, real providers instead of mocked context modules 2026-08-08 18:04:04 -06:00
DonatePage.js ui: only the top modal answers Escape, and the audited widths 2026-08-08 18:05:49 -06:00
Download.cy.js Download forms: allow a frequency of "Once" (#804) 2026-10-09 15:00:24 -06:00
Download.js app: api helpers report failure instead of returning an empty value (#736) 2026-09-26 17:47:32 -06:00
Download.test.js app: number fields no longer throw "e.preventDefault is not a function" (#735) 2026-09-26 17:41:52 -06:00
DownloaderSelector.test.js app: api helpers report failure instead of returning an empty value (#736) 2026-09-26 17:47:32 -06:00
ErrorBoundary.js ui: nine leaf files off Semantic, and the components they needed 2026-08-08 18:04:00 -06:00
FileBrowser.js A directory rename is finished by the file worker, not the request (#950) 2026-11-07 13:09:33 -07:00
FileBrowser.test.js A directory rename is finished by the file worker, not the request (#950) 2026-11-07 13:09:33 -07:00
FilePreview.js 3D previews load ASCII STLs, stand upright, and fit the preview modal (#952) 2026-11-07 15:33:58 -07:00
FilePreview.test.js Preview markdown files formatted, with a raw toggle (#780) 2026-10-05 13:26:42 -06:00
FilePreviewTracking.test.js Fix file view tracking: docs mark viewed, previews count one view (#786) 2026-10-08 15:04:13 -06:00
Files.js A directory rename is finished by the file worker, not the request (#950) 2026-11-07 13:09:33 -07:00
FilesRefreshProgress.test.js A directory rename is finished by the file worker, not the request (#950) 2026-11-07 13:09:33 -07:00
Flasher.js app: api helpers report failure instead of returning an empty value (#736) 2026-09-26 17:47:32 -06:00
Flasher.test.js app: api helpers report failure instead of returning an empty value (#736) 2026-09-26 17:47:32 -06:00
Headline.js ui: nine leaf files off Semantic, and the components they needed 2026-08-08 18:04:00 -06:00
HelpModal.js ui: thirty-five files off Semantic, leaving fifteen 2026-08-08 18:04:01 -06:00
KeyboardShortcutsProvider.js ui: the last of Semantic UI, in name and in dead CSS 2026-08-08 18:05:54 -06:00
Map.js Add a Solar calculator (#778) 2026-10-04 18:36:45 -06:00
Map.test.js review: name the icon-only controls, and make two guards mean what they say 2026-08-08 18:05:50 -06:00
mapPoiPopup.js map: clicking a POI shows its kind, detail, elevation and coordinates (#738) 2026-09-27 08:23:03 -06:00
MapPoiPopup.test.js map: clicking a POI shows its kind, detail, elevation and coordinates (#738) 2026-09-27 08:23:03 -06:00
MapPreview.test.js Map previews that never drew, and a Docker map with no world under it (#658) 2026-08-11 20:37:23 -06:00
MapSearchView.js app: api helpers report failure instead of returning an empty value (#736) 2026-09-26 17:47:32 -06:00
MapSearchView.test.js app: api helpers report failure instead of returning an empty value (#736) 2026-09-26 17:47:32 -06:00
MapTables.test.js Add a Solar calculator (#778) 2026-10-04 18:36:45 -06:00
MapViewer.js Add a Solar calculator (#778) 2026-10-04 18:36:45 -06:00
MapViewer.test.js Add a Solar calculator (#778) 2026-10-04 18:36:45 -06:00
MarkdownPreview.js Preview markdown files formatted, with a raw toggle (#780) 2026-10-05 13:26:42 -06:00
MarkdownPreview.test.js Preview markdown files formatted, with a raw toggle (#780) 2026-10-05 13:26:42 -06:00
ModelPreview.test.js 3D previews load ASCII STLs, stand upright, and fit the preview modal (#952) 2026-11-07 15:33:58 -07:00
Nav.js Add a Repos module that mirrors git repositories (#783) 2026-10-07 15:16:58 -06:00
Nav.test.js Bookmarks: a nav menu of user links, stored in bookmarks.yaml (#729) 2026-09-26 13:11:36 -06:00
OtherSearchView.test.js Other search tab: search Channels by name, add Domains and Playlists, fix the estimate (#785) 2026-10-07 18:22:12 -06:00
otp.js Move One-Time Pad encryption to the browser (#479) 2026-06-13 13:52:34 -06:00
otp.test.js Move One-Time Pad encryption to the browser (#479) 2026-06-13 13:52:34 -06:00
Placeholder.js ui: Common.js and thirteen more files off Semantic 2026-08-08 18:04:00 -06:00
Playlists.js review: the scan the first two commits needed 2026-08-08 18:05:53 -06:00
Playlists.test.js Add ordered collections (playlists): polymorphic items + item API (#475) 2026-06-11 19:46:34 -06:00
Repos.js Add a Repos module that mirrors git repositories (#783) 2026-10-07 15:16:58 -06:00
Repos.test.js Add a Repos module that mirrors git repositories (#783) 2026-10-07 15:16:58 -06:00
Search.js Other search tab: search Channels by name, add Domains and Playlists, fix the estimate (#785) 2026-10-07 18:22:12 -06:00
SearchFilterModal.test.js ui: thirty-five files off Semantic, leaving fifteen 2026-08-08 18:04:01 -06:00
SearchSuggestions.test.js Add a Repos module that mirrors git repositories (#783) 2026-10-07 15:16:58 -06:00
Share.js files: left-align the preview toolbar (#698) 2026-09-03 16:03:17 -06:00
ShortcutHint.js Displaying cmd+k/ctrl+k global search keyboard shortcut suggestion. 2026-02-23 16:07:22 -07:00
SortableTable.js review: the 375px phone this fix had not been measured on (#662) 2026-08-13 11:38:49 -06:00
StatisticsPage.test.js app: Flasher saved configs and Statistics distinguish pending from empty (#733) 2026-09-26 17:05:02 -06:00
StatusLoaded.test.js app: status and settings contexts say whether their first poll landed (#734) 2026-09-26 17:25:46 -06:00
Tables.js ui: nine leaf files off Semantic, and the components they needed 2026-08-08 18:04:00 -06:00
TaggedDeleteConfirmModal.js ui: let a confirmation choose its width 2026-08-08 18:05:51 -06:00
TaggedDeleteConfirmModal.test.js ui: let a confirmation choose its width 2026-08-08 18:05:51 -06:00
Theme.tsx ui: the last of Semantic UI, in name and in dead CSS 2026-08-08 18:05:54 -06:00
ThemeProvider.test.js test: act on review — observe the wiring, and stop the soft assertions 2026-08-08 18:05:45 -06:00
ThemeSamplePage.js The Settings upgrade can switch to a chosen branch (#954) 2026-11-08 08:49:26 -07:00
Upload.js ui: two upload dialogs that had drifted apart (#664) 2026-08-13 15:15:04 -06:00
Upload.test.js ui: two upload dialogs that had drifted apart (#664) 2026-08-13 15:15:04 -06:00
Vars.js Add a Repos module that mirrors git repositories (#783) 2026-10-07 15:16:58 -06:00
VideoEditMenu.js videos: transcode can remove the audio stream (silent video) (#737) 2026-09-26 17:49:14 -06:00
VideoEditMenu.test.js videos: transcode can remove the audio stream (silent video) (#737) 2026-09-26 17:49:14 -06:00
VideoExtras.test.js app: video comments and description distinguish pending from empty (#727) 2026-09-26 11:22:37 -06:00
VideoPlayer.js Resume videos and audio where the user left off; show progress on cards (#791) 2026-10-08 17:29:22 -06:00
VideoPlayer.test.js videos: address review — tighten auto-caption detection 2026-07-16 18:29:18 -06:00
Videos.js videos: codec download preferences with transcode and strict-fail options (#701) 2026-09-07 09:12:00 -06:00
VncToggle.test.js ui: Common.js and thirteen more files off Semantic 2026-08-08 18:04:00 -06:00
Zim.js zim: recompute the outdated-Zims flag after startup and on Delete (#706) 2026-09-12 15:19:36 -06:00
Zim.test.js zim: recompute the outdated-Zims flag after startup and on Delete (#706) 2026-09-12 15:19:36 -06:00