Repository navigation
Music copies are one play; backups carry no tokens; LAN apps keep their origin - #363
Merged
Merged
Conversation
- A LAN app's logo fetch stays on that app's origin - scheme, host AND port: one NAS answers for a dozen apps on one address, a redirect to another port is another app (the same-origin idea from Sentinel #356). - The endpoint policy judges the app's address once instead of every hop: it is for base URLs and refused an icon link with a query, so SoulSync (/static/pwa-icon-192.png?v=...) showed no logo since #353. Live: Radarr, Sonarr and SoulSync logos from the LAN all arrive. test_fresh_install +2 (another port refused; a query icon fetched). Co-Authored-By: Claude Opus 5.5 <[email protected]>
… every start The start-up pass set every SQLite file under data/ to 0600, the backups included: the backup written at 22:47 could be copied off the NAS share until the 23:43 restart turned it 0600 (2026-11-14), and a manual chmod would be undone by the next start. Now: - _secure_db_files gives files under data/backups 0640 (BACKUP_MODE); - the nightly DB backup writes its snapshot 0640; - the cache snapshot is written 0640, its folders 0750. The live database, its sidecars, the caches, the vector store and .env stay 0600 (a live SQLite file is never copied; .env holds the tokens). tests/test_backup_perms.py (POSIX modes, checked in CI) and test_backup_retention +1 (a new snapshot is 0640). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reading the owner's music library whole stored copies: Plex gives every
copy of a track (album, remaster, compilation) the same lastViewedAt second
while its history holds one play ('Lovely Day' three times at 00:46:51,
one of them without genres), and a song stored from the listing and from
the history landed twice, the two stamps 147 s apart (the 90-second
same-play rule is for video).
- plex_sync.drop_music_copies: per song and second one listing entry stays
(the one with a genre), before the three-in-a-second mark rule counts.
- _same_play_s: a song's same-play window is its length (a history event
without a length: 6 minutes); video keeps 90 s. Used where a history
event meets the listing and the stored plays.
- A history event of another copy of a listed song is that same play.
- Schema 4 migration: per song and second one row stays (with genres, a
play rather than 'marked'), and a second row of a song inside the first
one's length goes. On a copy of the owner's backup: music plays from
Plex 48,258 -> 40,204, 'marked' 628 -> 105 (137 groups of only marked
copies now count as the play they were); Spotify, films, shows and anime
untouched.
tests/test_music_copies.py (11 checks: sync, history match, migration);
test_single_marks pins 'generation 3 or later'.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…to claude/music-copies
#362 followed an arr's login redirect by hand on the asked host; one NAS answers for a dozen apps, one per port. The probe now uses the LAN logo fetch's check (setup_icons._lan_ok): same scheme, host and port, the endpoint policy judging the app's address once. Live: Radarr, Sonarr and SoulSync found as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…, the bots' three Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reworked after a look at how comparable self-hosted apps do it (Sonarr, Tautulli, Plex, Home Assistant, Immich, Jellyfin): they back up what cannot be rebuilt (database, config), skip caches, keep 0600, and Plex keeps its token out of its database backups. - scheduler._strip_secrets: the backup copy's users.plex_token (and the session tokens) are blanked with secure_delete on, the copy left one file and checked again. A restore asks each member to sign in once (the token is refreshed at every sign-in); the server's token lives in .env. - Modes: backups 0600/0700 like the database (connection.backup_modes); BACKUP_GROUP_READABLE=true makes them 0640/0750 for a NAS user in the app's group, and the start-up pass follows the setting instead of forcing 0600. The live database and .env stay 0600. - BACKUP_CACHES (default false): the cache and vector-store snapshot from 1.2.0 only when asked for; switched off, a snapshot already written is removed. The demo builder names both settings when they are missing. - Both settings env-only (.env.example documents them). tests/test_backup_perms.py reworked (tokens gone from the file bytes, live DB keeps them, modes per setting, cache snapshot off/on/removed); test_backup_retention expects 0600; test_cache_snapshot turns the option on. Co-Authored-By: Claude Opus 5.5 <[email protected]>
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three fixes found after #358 brought the owner's Plexamp history in.
1. One song played is one play.
Two causes, both measured on a fresh backup of the owner's install:
lastViewedAtsecond, while its history holds one play. Example: "Lovely Day" three times at 00:46:51, one of the copies without genres.The fix:
plex_sync.drop_music_copieskeeps one listing entry per song and second, the one with a genre. It runs before the three-in-a-second mark rule counts._same_play_s: a song's same-play window is its length. A history event without a length gets 6 minutes. Video keeps 90 s.marked). It also drops a second row of the same song that falls inside the first one's length.On a copy of the owner's real backup:
markedIn 137 groups only
markedcopies were stored; their kept row now counts as the play it was. The taste profile had counted all the copies.2. Backups: no tokens inside, 0600 by default, the cache snapshot opt-in.
This follows a look at how comparable self-hosted apps handle backups (Sonarr, Tautulli, Plex, Home Assistant, Immich, Jellyfin). They back up only what cannot be rebuilt, the database and config. They skip caches, keep files 0600, and Plex keeps its token out of its database backups.
scheduler._strip_secretsblanksusers.plex_tokenand the session tokens in the backup copy, withsecure_deleteon so the bytes are overwritten. It leaves the copy as one file and checks it again..env, never in the database.BACKUP_GROUP_READABLE=truemakes them 0640/0750, for a NAS user in the app's group.chmodwas gone after the next restart. It now follows this setting..envstay 0600.BACKUP_CACHES, off by default. The cache and vector-store snapshot that shipped in 1.2.0 runs only when asked for. When the setting is off, an existing snapshot (~2 GB) is removed. The demo builder names both settings when they are missing..envonly, documented in.env.example.3. LAN apps keep to their own origin, port included.
/static/pwa-icon-192.png?v=…) since Launch prep: one design language, security fixes, image tracks, cache backups, demo builder #353.CHANGELOG Unreleased covers these fixes and #360–#362.
Tests: 357/357.
test_music_copies(new, 11 checks): sync, history match, migration.test_backup_perms(new): token bytes gone from the backup file while the live DB keeps them; modes per setting (POSIX, checked in CI); cache snapshot off, on, then removed.test_backup_retention+1: a new snapshot is 0600 by default.test_fresh_install+2: another port is refused; an icon URL with a query is fetched.test_single_marksnow pins "generation 3 or later".After deploying: the migration runs once at start. The nightly backup from before stays as a fallback.
🤖 Generated with Claude Code