From a86c539a952d8a118bdb63cc55ac383278178ea4 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Sun, 26 Jul 2020 22:44:09 +0100 Subject: [PATCH] Untested: add config migration from automatic sync storage --- src/lib/config.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/lib/config.ts b/src/lib/config.ts index f47cc319..108eece5 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -1551,6 +1551,24 @@ export async function update() { "vmaps", ].forEach(settingName => updateAll([settingName], updateSetting)) set("configversion", "1.9") + } + case "1.9": { + const local = (await browser.storage.local.get(CONFIGNAME))[CONFIGNAME] + const sync = (await browser.storage.sync.get(CONFIGNAME))[CONFIGNAME] + // Possible combinations: + // storage:storageloc_setting => winning storageloc setting + // l:l, s:* => l + // l:undefined, s:l => l + // l:undefined, s:s => s + // l: undefined, s:undefined => s + // l:s, s:* => s + const current_storageloc = local?.storageloc !== undefined ? local.storageloc : sync?.storageloc !== undefined ? sync.storageloc : "sync" + if (current_storageloc == "sync") { + await pull() + } else if (current_storageloc != "local") { + throw new Error("storageloc was set to something weird: " + current_storageloc + ", automatic migration of settings was not possible.") + } + set("configversion", "1.10") updated = true // NB: when adding a new updater, move this line to the end of it } }