Fix data archives and restores failing on their own lock
startDataBackupRun already holds the backup run lock, but the archive (createDataBackup) and restoreDataBackup took it again, so every run failed a few seconds in with "Another backup or restore is already running". The writer and the restore now take no lock of their own. The run's notice (archiving, restoring, or why it failed) moves to its own line under the actions row so the buttons don't shift, and archiving reads in gray rather than the warning colour. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -2,6 +2,7 @@ import { describe, expect, test } from "bun:test";
|
||||
import AppError from "@/src/utils/app-error";
|
||||
import { BootId, grabDataBackupRun, startDataBackupRun } from "./data-backup-run";
|
||||
import { isBackupRunning } from "./with-backup-run-lock";
|
||||
import restoreDataBackup from "./restore-data-backup";
|
||||
|
||||
function deferred() {
|
||||
let resolve!: (name: string) => void;
|
||||
@@ -80,4 +81,19 @@ describe("startDataBackupRun", () => {
|
||||
await settle();
|
||||
expect(grabDataBackupRun().status).toBe("done");
|
||||
});
|
||||
|
||||
test("a restore runs under the run's lock instead of taking it again", async () => {
|
||||
startDataBackupRun({
|
||||
kind: "restore",
|
||||
task: async () =>
|
||||
(await restoreDataBackup({ backup_name: "missing.tar.gz" }))
|
||||
.restored_name,
|
||||
});
|
||||
await settle();
|
||||
|
||||
const failed = grabDataBackupRun();
|
||||
expect(failed.status).toBe("failed");
|
||||
expect(failed.error).toBe("Archive not found");
|
||||
expect(isBackupRunning()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user