Skip to content

Commit

Permalink
fix #2925
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Aug 29, 2017
1 parent 572aecc commit beb7933
Show file tree
Hide file tree
Showing 8 changed files with 256 additions and 163 deletions.
3 changes: 2 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"eqeqeq": true,
"esnext": true,
"globals": {
"chrome": false,
"browser": false, // global variable in Firefox, Edge
"chrome": false, // global variable in Chromium, Chrome, Opera
"Components": false, // global variable in Firefox
"safari": false,
"self": false,
Expand Down
1 change: 1 addition & 0 deletions platform/webext/background.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<script src="lib/publicsuffixlist.js"></script>
<script src="js/vapi-common.js"></script>
<script src="js/vapi-background.js"></script>
<script src="js/vapi-cachestorage.js"></script><!-- Optional -->
<script src="js/background.js"></script>
<script src="js/utils.js"></script>
<script src="js/uritools.js"></script>
Expand Down
9 changes: 7 additions & 2 deletions platform/webext/from-legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
(function() {
let µb = µBlock;
let migratedKeys = new Set();
let reCacheStorageKeys = /^(?:assetCacheRegistry|assetSourceRegistry|cache\/.+|selfie)$/;

let migrateAll = function(callback) {
let migrateKeyValue = function(details, callback) {
Expand All @@ -40,7 +41,11 @@
migratedKeys.add(details.key);
let bin = {};
bin[details.key] = JSON.parse(details.value);
self.browser.storage.local.set(bin, callback);
if ( reCacheStorageKeys.test(details.key) ) {
vAPI.cacheStorage.set(bin, callback);
} else {
vAPI.storage.set(bin, callback);
}
};

let migrateNext = function() {
Expand All @@ -62,7 +67,7 @@
self.browser.runtime.sendMessage({ what: 'webext:storageMigrateDone' });
return callback();
}
self.browser.storage.local.set({ legacyStorageMigrated: true });
vAPI.storage.set({ legacyStorageMigrated: true });
migrateNext();
});
};
Expand Down
Loading

0 comments on commit beb7933

Please sign in to comment.