From 436a970f7b94d31a54c6767e0bee482bd43417d6 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Thu, 26 Nov 2026 23:53:37 -0500 Subject: [PATCH] fix(backup): a restore says Subsonic apps are signed out, and restores ListenBrainz switched off (#8104) The backup leaves out each person's Subsonic password and ListenBrainz token, which are sealed under the stream secret, but no restore message said so. The CLI and docs sent people to Admin for keys that live in each person's own Settings, and the web said nothing. All three now say that Subsonic apps are signed out and where to make a new Subsonic password and save the ListenBrainz token. listenbrainz_enabled travelled without the token, so a restored account read as on but unable to send. It is now left out too and restores off. Co-Authored-By: Claude Opus 5.5 --- cmd/minstrel/restore.go | 2 +- docs/hosting.md | 11 ++++++++--- internal/backup/backup_test.go | 18 ++++++++++-------- internal/backup/tables.go | 8 ++++++-- web/src/lib/components/auth/RestoreForm.svelte | 4 ++++ web/src/routes/register/register.test.ts | 1 + 6 files changed, 30 insertions(+), 14 deletions(-) diff --git a/cmd/minstrel/restore.go b/cmd/minstrel/restore.go index cbe214e1..32ca57d0 100644 --- a/cmd/minstrel/restore.go +++ b/cmd/minstrel/restore.go @@ -72,5 +72,5 @@ func printRestored(w io.Writer, m backup.Manifest) { m.CreatedAt.Local().Format("2 Jan 2006 15:04 MST"), m.Build, m.Rows["users"], m.Rows["tracks"], m.Rows["playlists"]) _, _ = fmt.Fprintln(w, "Start the server. The library scan (at startup, or Scan now under Admin › Library) finds each music file at its path, and the artwork, tags and analysis the backup leaves out are fetched and worked out again.") - _, _ = fmt.Fprintln(w, "Everyone signs in with the password they had. Keys for other services, and the backup's own destination, are entered again in Admin.") + _, _ = fmt.Fprintln(w, "Everyone signs in with the password they had. Subsonic apps are signed out: each person makes a new Subsonic password in their own Settings, and saves their ListenBrainz token there again. Keys for other services, and the backup's own destination, are entered again in Admin.") } diff --git a/docs/hosting.md b/docs/hosting.md index 92384518..50f197d3 100644 --- a/docs/hosting.md +++ b/docs/hosting.md @@ -144,9 +144,14 @@ the place of what the scan found. The library scan then finds each file, and the artwork, tags, fingerprints and loudness are fetched or worked out again over the following hours. Keys -for other services (ListenBrainz, AcoustID, artwork and tag providers, -email) and the backup's own destination are entered again -under **Admin**. An app that synced with the old server starts its sync over. +for other services (AcoustID, artwork and tag providers, email) and the +backup's own destination are entered again under **Admin**. An app that +synced with the old server starts its sync over. + +Subsonic apps are signed out. Each person makes a new Subsonic password in +their own **Settings › Connections** and enters it in their apps, and saves +their ListenBrainz token there again (ListenBrainz comes back switched off +until they do). An app that signs in with an API key keeps working. ## Android app diff --git a/internal/backup/backup_test.go b/internal/backup/backup_test.go index 7ffafb4f..9a629682 100644 --- a/internal/backup/backup_test.go +++ b/internal/backup/backup_test.go @@ -115,8 +115,8 @@ func TestARestoredInstanceHoldsWhatTheBackupHeld_Integration(t *testing.T) { pool := dbtest.Pool(t) ctx := context.Background() - user := mustID(t, pool, `INSERT INTO users (username, password_hash, api_token_hash, listenbrainz_token) - VALUES ($1, 'hash', 'backup-token', 'lb-token') RETURNING id::text`, dbtest.TestUserPrefix+"backup") + user := mustID(t, pool, `INSERT INTO users (username, password_hash, api_token_hash, listenbrainz_token, listenbrainz_enabled) + VALUES ($1, 'hash', 'backup-token', 'lb-token', true) RETURNING id::text`, dbtest.TestUserPrefix+"backup") artist := mustID(t, pool, `INSERT INTO artists (name, sort_name, artist_art_source) VALUES ('Artist', 'artist', 'none') RETURNING id::text`) album := mustID(t, pool, `INSERT INTO albums (title, sort_title, artist_id, cover_art_source, cover_art_path) VALUES ('Album', 'album', $1, 'mbcaa', '/data/covers/a.jpg') RETURNING id::text`, artist) @@ -195,16 +195,18 @@ func TestARestoredInstanceHoldsWhatTheBackupHeld_Integration(t *testing.T) { } } - // What the backup leaves out comes back unset, so the server asks for the - // credential again and redoes the art and tags. + // What the backup leaves out comes back unset, so the credential is + // entered again and the art and tags are redone. ListenBrainz comes back + // off, since it can't send until its token is saved again. var lbToken, coverSource, tagSource *string - if err := pool.QueryRow(ctx, `SELECT u.listenbrainz_token, al.cover_art_source, tr.tag_source + var lbEnabled bool + if err := pool.QueryRow(ctx, `SELECT u.listenbrainz_token, u.listenbrainz_enabled, al.cover_art_source, tr.tag_source FROM users u, albums al, tracks tr WHERE u.id = $1 AND al.id = $2 AND tr.id = $3`, - user, album, track).Scan(&lbToken, &coverSource, &tagSource); err != nil { + user, album, track).Scan(&lbToken, &lbEnabled, &coverSource, &tagSource); err != nil { t.Fatal(err) } - if lbToken != nil || coverSource != nil || tagSource != nil { - t.Errorf("token %v, cover source %v, tag source %v; want all unset", lbToken, coverSource, tagSource) + if lbToken != nil || lbEnabled || coverSource != nil || tagSource != nil { + t.Errorf("token %v, enabled %v, cover source %v, tag source %v; want all unset", lbToken, lbEnabled, coverSource, tagSource) } // The change feed carries on after the restored ids. diff --git a/internal/backup/tables.go b/internal/backup/tables.go index 85a4e397..3afc0766 100644 --- a/internal/backup/tables.go +++ b/internal/backup/tables.go @@ -13,7 +13,8 @@ package backup // // Omit names columns left out of the file. They restore to their defaults: // - a credential Minstrel stores sealed, which only the server holding the -// stream secret could open, so the restored server asks for it again; +// stream secret could open, so it is entered again after the restore, +// and a switch that is only on while that credential is set; // - a marker saying work on an excluded table is done (a tag source, an art // source), so the restored server does that work again rather than // believing it has the result. @@ -26,7 +27,10 @@ type Table struct { // each after every table it references. There are no self-referencing // tables, so no table needs its rows loaded in depth order. var Tables = []Table{ - {Name: "users", Omit: []string{"subsonic_password", "listenbrainz_token"}}, + // Each person makes a new Subsonic password and saves their ListenBrainz + // token again in their own Settings. ListenBrainz restores to off, since + // it can't send without the token. + {Name: "users", Omit: []string{"subsonic_password", "listenbrainz_token", "listenbrainz_enabled"}}, // The library's identity. Every like, play and playlist entry hangs off a // track id, so the rows travel even though a scan could rebuild most of diff --git a/web/src/lib/components/auth/RestoreForm.svelte b/web/src/lib/components/auth/RestoreForm.svelte index fc39711e..1bffc939 100644 --- a/web/src/lib/components/auth/RestoreForm.svelte +++ b/web/src/lib/components/auth/RestoreForm.svelte @@ -58,6 +58,10 @@

The library scan finds each music file and fetches the artwork and tags again.

+

+ Subsonic apps are signed out: each person makes a new Subsonic password, and saves their + ListenBrainz token again, in Settings › Connections. +

Sign in {:else} diff --git a/web/src/routes/register/register.test.ts b/web/src/routes/register/register.test.ts index 952ca6b7..0482e7a1 100644 --- a/web/src/routes/register/register.test.ts +++ b/web/src/routes/register/register.test.ts @@ -186,6 +186,7 @@ describe('/register page', () => { const done = await screen.findByTestId('restore-done'); expect(done.textContent).toMatch(/Restored 2 accounts\.\s+Minstrel is restarting to load them; in a few seconds, sign in with the password you had\./); expect(done.textContent).toMatch(/library scan finds each music file/); + expect(done.textContent).toMatch(/Subsonic apps are signed out/); expect(within(done).getByRole('link', { name: /^sign in$/i })).toHaveAttribute('href', '/login'); });