1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-29 16:07:40 +01:00

migration error handling

This commit is contained in:
Jelle van Snik 2023-02-12 16:23:55 +01:00
parent f46263385b
commit df5f1a5fdb

View file

@ -44,9 +44,16 @@ export async function initializeStores() {
// Migrate over each version
let mostRecentData = data;
for (const version of relevantVersions) {
if (version.migrate)
mostRecentData = await version.migrate(mostRecentData);
try {
for (const version of relevantVersions) {
if (version.migrate)
mostRecentData = await version.migrate(mostRecentData);
}
} catch (err) {
console.error(`FAILED TO MIGRATE STORE ${internal.key}`, err);
// reset store to lastest version create
mostRecentData =
relevantVersions[relevantVersions.length - 1].create?.() ?? {};
}
store.save(mostRecentData);