Untested: add config migration from automatic sync storage

This commit is contained in:
Oliver Blanthorn 2020-07-26 22:44:09 +01:00
parent db8be417e9
commit a86c539a95
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3

View file

@ -1551,6 +1551,24 @@ export async function update() {
"vmaps", "vmaps",
].forEach(settingName => updateAll([settingName], updateSetting)) ].forEach(settingName => updateAll([settingName], updateSetting))
set("configversion", "1.9") 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 updated = true // NB: when adding a new updater, move this line to the end of it
} }
} }