Skip to content

Commit fbd1cdc

Browse files
committed
set version number in init logic
1 parent 4679ac5 commit fbd1cdc

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

packages/storage/src/index.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -368,17 +368,7 @@ function createStorage(): WxtStorage {
368368
driverKey,
369369
driverMetaKey,
370370
]);
371-
if (value == null) {
372-
if (targetVersion > 1) {
373-
await setMeta(driver, driverKey, { v: targetVersion });
374-
if (debug === true) {
375-
console.debug(
376-
`[@wxt-dev/storage] Set meta for ${driverKey} v${targetVersion}`,
377-
);
378-
}
379-
}
380-
return;
381-
}
371+
if (value == null) return;
382372

383373
const currentVersion = meta?.v ?? 1;
384374
if (currentVersion > targetVersion) {
@@ -446,6 +436,9 @@ function createStorage(): WxtStorage {
446436
const getOrInitValue = () =>
447437
initMutex.runExclusive(async () => {
448438
const value = await driver.getItem<any>(driverKey);
439+
if (value == null && targetVersion > 1)
440+
await setMeta(driver, driverKey, { v: targetVersion });
441+
449442
// Don't init value if it already exists or the init function isn't provided
450443
if (value != null || opts?.init == null) return value;
451444

0 commit comments

Comments
 (0)