fix(ext/sw): atomic chrome.storage update in restore_backup
Single set({vaultConfig, imageBase64?}) instead of two sequential sets,
so a partial-write window can't leave vaultConfig pointing to the new
remote while imageBase64 still references the old vault.
This commit is contained in:
@@ -483,10 +483,11 @@ export async function handle(
|
||||
repoPath: msg.newRemote.repoPath,
|
||||
apiToken: msg.newRemote.apiToken,
|
||||
};
|
||||
await chrome.storage.local.set({ vaultConfig: cfg });
|
||||
const storageUpdate: Record<string, unknown> = { vaultConfig: cfg };
|
||||
if (out.reference_jpg) {
|
||||
await chrome.storage.local.set({ imageBase64: out.reference_jpg });
|
||||
storageUpdate.imageBase64 = out.reference_jpg;
|
||||
}
|
||||
await chrome.storage.local.set(storageUpdate);
|
||||
|
||||
// Make sure the SW's gitHost cache picks up the new config.
|
||||
state.gitHost = newHost;
|
||||
|
||||
Reference in New Issue
Block a user