Stop orphan game links from blocking global imports
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:
parent
98c442a9cd
commit
d030c3f59f
9 changed files with 137 additions and 9 deletions
|
|
@ -8,13 +8,15 @@ import {
|
|||
getToolboxSnapshot as dbGetToolboxSnapshot,
|
||||
getToolboxes as dbGetToolboxes,
|
||||
mutateToolboxStorage as dbMutateToolboxStorage,
|
||||
removeOrphanLinks as dbRemoveOrphanLinks,
|
||||
setSetting as dbSetSetting,
|
||||
} from "../../../utils/indexedDbStorage.js";
|
||||
import {
|
||||
compactToolboxesForStorage,
|
||||
moduleStorageKey,
|
||||
normalizeToolbox,
|
||||
prepareModuleDataForStorage
|
||||
prepareModuleDataForStorage,
|
||||
pruneGameLinks
|
||||
} from "./toolboxStorage.js";
|
||||
import { applyModuleDataValue, removeModuleDataKeys } from "./optimisticModuleData.js";
|
||||
import { createPersistenceQueue } from "./persistenceQueue.js";
|
||||
|
|
@ -62,7 +64,7 @@ async function readStoredState({ preservedModuleData = {}, refreshedModuleKeys =
|
|||
}
|
||||
return {
|
||||
toolboxes: normalizedToolboxes,
|
||||
links: links && typeof links === "object" ? links : {},
|
||||
links: pruneGameLinks(links, normalizedToolboxes),
|
||||
moduleData,
|
||||
toastPosition: toastPosition === "left" ? "left" : "right"
|
||||
};
|
||||
|
|
@ -107,6 +109,8 @@ export function useIndexedToolboxes(onError) {
|
|||
let cancelled = false;
|
||||
async function loadStore() {
|
||||
try {
|
||||
// Le nettoyage est accessoire : un échec ne doit pas empêcher le chargement.
|
||||
await dbRemoveOrphanLinks().catch(() => 0);
|
||||
const storedState = await readStoredState();
|
||||
if (cancelled) return;
|
||||
queue.initialize(storedState);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue