fix: a new server takes a backup after its first scan, and restarts to load the restored settings (#6786)
release / govulncheck (push) Successful in 16s
release / go (push) Failing after 49s
release / web (push) Successful in 1m9s
release / integration (push) Failing after 4m14s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / android (push) Canceled after 4m38s
release / Build signed APK (push) Canceled after 4m38s
release / govulncheck (push) Successful in 16s
release / go (push) Failing after 49s
release / web (push) Successful in 1m9s
release / integration (push) Failing after 4m14s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / android (push) Canceled after 4m38s
release / Build signed APK (push) Canceled after 4m38s
A one-off end-to-end run of the :dev image (scratch Postgres, generated FLAC files, no outbound network) found that the web restore, done the way docs/hosting.md describes, was refused with not_empty: a new server's startup scan fills the library before anyone signs up, and Restore counted tracks as occupied. The command-line restore passed the same run. - Restore now asks only that the instance has no accounts. The library the first scan found is replaced by the backup's (every foreign key into artists/albums/tracks cascades or sets null), and the restore locks the library tables so a running scan waits rather than adding to them. - Settings are read once at boot by about ten services, the library folders among them, so after a web restore the server ran on its defaults until restarted. The restore endpoint now answers, then asks the process to restart in place (syscall.Exec of the same binary, arguments and environment), which needs no container restart policy. The startup scan of the restarted server replaces the scan the endpoint used to start. - The restore form says Minstrel is restarting; the docs say a scanned new server still takes a backup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -75,7 +75,7 @@ export async function register(opts: {
|
||||
void sendTimezoneIfStale();
|
||||
}
|
||||
|
||||
export type RestoreResult = { accounts: number; scan_started: boolean };
|
||||
export type RestoreResult = { accounts: number; restarting: boolean };
|
||||
|
||||
/**
|
||||
* Loads a backup file into a new server, which has no accounts yet. The file
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
case 'newer_backup':
|
||||
return 'That backup was made by a newer Minstrel. Update this server first, then restore it.';
|
||||
case 'not_empty':
|
||||
return 'This server already has accounts or a library, so it can’t take a backup.';
|
||||
return 'This server already has accounts, so it can’t take a backup.';
|
||||
case 'too_large':
|
||||
return 'That file is larger than a backup can be.';
|
||||
default:
|
||||
@@ -50,12 +50,13 @@
|
||||
{#if done}
|
||||
<div class="space-y-3" role="status" data-testid="restore-done">
|
||||
<p class="text-sm text-text-primary">
|
||||
Restored {plural(done.accounts, 'account', 'accounts')}. Sign in with the password you had.
|
||||
Restored {plural(done.accounts, 'account', 'accounts')}.
|
||||
{done.restarting
|
||||
? 'Minstrel is restarting to load them; in a few seconds, sign in with the password you had.'
|
||||
: 'Sign in with the password you had.'}
|
||||
</p>
|
||||
<p class="text-sm text-text-secondary">
|
||||
{done.scan_started
|
||||
? 'The library scan has started: it finds each music file and fetches the artwork and tags again.'
|
||||
: 'Start a library scan under Admin › Library once you’re signed in.'}
|
||||
The library scan finds each music file and fetches the artwork and tags again.
|
||||
</p>
|
||||
<a href="/login" class="block w-full rounded bg-accent px-3 py-2 text-center font-medium text-background">Sign in</a>
|
||||
</div>
|
||||
|
||||
@@ -166,7 +166,7 @@ describe('/register page', () => {
|
||||
|
||||
test('a new server restores a backup with the setup token, then sends you to sign in', async () => {
|
||||
(getSetupStatus as ReturnType<typeof vi.fn>).mockResolvedValue({ setup_required: true });
|
||||
(restoreBackup as ReturnType<typeof vi.fn>).mockResolvedValue({ accounts: 2, scan_started: true });
|
||||
(restoreBackup as ReturnType<typeof vi.fn>).mockResolvedValue({ accounts: 2, restarting: true });
|
||||
render(RegisterPage);
|
||||
await fireEvent.click(await screen.findByRole('button', { name: /restore a backup/i }));
|
||||
expect(screen.getByRole('heading', { name: /restore a backup/i })).toBeInTheDocument();
|
||||
@@ -179,8 +179,8 @@ describe('/register page', () => {
|
||||
|
||||
await waitFor(() => expect(restoreBackup).toHaveBeenCalledWith(file, '0123abcd'));
|
||||
const done = await screen.findByTestId('restore-done');
|
||||
expect(done.textContent).toMatch(/Restored 2 accounts\. Sign in with the password you had\./);
|
||||
expect(done.textContent).toMatch(/library scan has started/);
|
||||
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(within(done).getByRole('link', { name: /^sign in$/i })).toHaveAttribute('href', '/login');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user