diff --git a/platform/webext/from-legacy.js b/platform/webext/from-legacy.js index 93edba2be..d69f5d2d2 100644 --- a/platform/webext/from-legacy.js +++ b/platform/webext/from-legacy.js @@ -27,21 +27,26 @@ (function() { let µb = µBlock; + let migratedKeys = new Set(); let migrateAll = function(callback) { - let mustRestart = false; - let migrateKeyValue = function(details, callback) { + // https://github.com/gorhill/uBlock/issues/2653 + // Be ready to deal graciously with corrupted DB. + if ( migratedKeys.has(details.key) ) { + callback(); + return; + } + migratedKeys.add(details.key); let bin = {}; bin[details.key] = JSON.parse(details.value); self.browser.storage.local.set(bin, callback); - mustRestart = true; }; let migrateNext = function() { self.browser.runtime.sendMessage({ what: 'webext:storageMigrateNext' }, response => { if ( response.key === undefined ) { - if ( mustRestart ) { + if ( migratedKeys.size !== 0 ) { self.browser.runtime.reload(); } else { callback();