Stop orphan game links from blocking global imports
All checks were successful
Validate and deploy Sokko G / validate (push) Successful in 20m13s
Validate and deploy Sokko G / deploy (push) Successful in 11s

A game link could outlive its toolbox when one tab linked a game while
another tab, unaware of that link, deleted the toolbox. Auto-backups and
manual exports then copied the orphan link, and the global import
rejected the whole file.

- Drop links to missing toolboxes inside the IndexedDB transaction.
- Remove orphan links already stored when the page loads.
- Ignore a link request to a toolbox that no longer exists.
- Leave orphan links out of exports and skip them on global import, so
  older backups import again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-11 15:12:34 +01:00
parent 98c442a9cd
commit d030c3f59f
9 changed files with 137 additions and 9 deletions

View file

@ -244,6 +244,24 @@ test("failed toolbox deletion preserves registry links and modules together", as
assert.deepEqual(queue.getCurrent(), initial);
});
test("a game cannot be linked to a toolbox that no longer exists", async () => {
let state = { toolboxes: [{ id: "kept", modules: [] }], links: { game: "kept" }, moduleData: {} };
const actions = useToolboxActions({
store: {
ready: true,
...state,
persistToolboxSnapshot: async (apply) => {
state = { ...state, ...apply(state) };
return true;
}
}
});
await actions.linkToolboxToGame("other", "deleted");
assert.deepEqual(state.links, { game: "kept" });
await actions.linkToolboxToGame("other", "kept");
assert.deepEqual(state.links, { game: "kept", other: "kept" });
});
test("storage mutations target independent records and preserve deferred media deletions", () => {
const expected = {
toolboxes: [{ id: "a", modules: [{ id: "media", type: "images" }] }],