mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-18 17:02:27 +02:00
Properly handle promise rejection from webext.storage.local() API
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/2604
This commit is contained in:
parent
8939a68e6d
commit
54cb5e2232
@ -63,10 +63,26 @@ const storageLocal = webext.storage.local;
|
|||||||
|
|
||||||
const cacheStorage = {
|
const cacheStorage = {
|
||||||
name: 'browser.storage.local',
|
name: 'browser.storage.local',
|
||||||
get: storageLocal.get.bind(storageLocal),
|
get: (...args) => {
|
||||||
set: storageLocal.set.bind(storageLocal),
|
return storageLocal.get(...args).catch(reason => {
|
||||||
remove: storageLocal.remove.bind(storageLocal),
|
console.log(reason);
|
||||||
clear: storageLocal.clear.bind(storageLocal),
|
});
|
||||||
|
},
|
||||||
|
set: (...args) => {
|
||||||
|
return storageLocal.set(...args).catch(reason => {
|
||||||
|
console.log(reason);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
remove: (...args) => {
|
||||||
|
return storageLocal.remove(...args).catch(reason => {
|
||||||
|
console.log(reason);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
clear: (...args) => {
|
||||||
|
return storageLocal.clear(...args).catch(reason => {
|
||||||
|
console.log(reason);
|
||||||
|
});
|
||||||
|
},
|
||||||
// Not all platforms support getBytesInUse
|
// Not all platforms support getBytesInUse
|
||||||
getBytesInUse: storageLocal.getBytesInUse
|
getBytesInUse: storageLocal.getBytesInUse
|
||||||
? storageLocal.getBytesInUse.bind(storageLocal)
|
? storageLocal.getBytesInUse.bind(storageLocal)
|
||||||
|
@ -265,7 +265,7 @@ const onUserSettingsReady = fetched => {
|
|||||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/1365
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/1365
|
||||||
// Wait for removal of invalid cached data to be completed.
|
// Wait for removal of invalid cached data to be completed.
|
||||||
|
|
||||||
const onCacheSettingsReady = async fetched => {
|
const onCacheSettingsReady = async (fetched = {}) => {
|
||||||
if ( fetched.compiledMagic !== µb.systemSettings.compiledMagic ) {
|
if ( fetched.compiledMagic !== µb.systemSettings.compiledMagic ) {
|
||||||
µb.compiledFormatChanged = true;
|
µb.compiledFormatChanged = true;
|
||||||
µb.selfieIsInvalid = true;
|
µb.selfieIsInvalid = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user