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 <noreply@anthropic.com>
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user