mirror of https://github.com/gorhill/uBlock.git
Mind rejected promises from vAPI.storage API
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/2604
This commit is contained in:
parent
7b3feca9fc
commit
98d4d24f9b
|
@ -90,7 +90,38 @@ vAPI.app = {
|
|||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
||||
vAPI.storage = webext.storage.local;
|
||||
vAPI.storage = {
|
||||
get(...args) {
|
||||
return webext.storage.local.get(...args).catch(reason => {
|
||||
console.log(reason);
|
||||
});
|
||||
},
|
||||
set(...args) {
|
||||
return webext.storage.local.set(...args).catch(reason => {
|
||||
console.log(reason);
|
||||
});
|
||||
},
|
||||
remove(...args) {
|
||||
return webext.storage.local.remove(...args).catch(reason => {
|
||||
console.log(reason);
|
||||
});
|
||||
},
|
||||
clear(...args) {
|
||||
return webext.storage.local.clear(...args).catch(reason => {
|
||||
console.log(reason);
|
||||
});
|
||||
},
|
||||
QUOTA_BYTES: browser.storage.local.QUOTA_BYTES,
|
||||
};
|
||||
|
||||
// Not all platforms support getBytesInUse
|
||||
if ( webext.storage.local.getBytesInUse instanceof Function ) {
|
||||
vAPI.storage.getBytesInUse = function(...args) {
|
||||
return webext.storage.local.getBytesInUse(...args).catch(reason => {
|
||||
console.log(reason);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
|
|
@ -63,30 +63,26 @@ const storageLocal = webext.storage.local;
|
|||
|
||||
const cacheStorage = {
|
||||
name: 'browser.storage.local',
|
||||
get: (...args) => {
|
||||
get(...args) {
|
||||
return storageLocal.get(...args).catch(reason => {
|
||||
console.log(reason);
|
||||
});
|
||||
},
|
||||
set: (...args) => {
|
||||
set(...args) {
|
||||
return storageLocal.set(...args).catch(reason => {
|
||||
console.log(reason);
|
||||
});
|
||||
},
|
||||
remove: (...args) => {
|
||||
remove(...args) {
|
||||
return storageLocal.remove(...args).catch(reason => {
|
||||
console.log(reason);
|
||||
});
|
||||
},
|
||||
clear: (...args) => {
|
||||
clear(...args) {
|
||||
return storageLocal.clear(...args).catch(reason => {
|
||||
console.log(reason);
|
||||
});
|
||||
},
|
||||
// Not all platforms support getBytesInUse
|
||||
getBytesInUse: storageLocal.getBytesInUse
|
||||
? storageLocal.getBytesInUse.bind(storageLocal)
|
||||
: undefined,
|
||||
select: function(selectedBackend) {
|
||||
let actualBackend = selectedBackend;
|
||||
if ( actualBackend === undefined || actualBackend === 'unset' ) {
|
||||
|
@ -113,6 +109,15 @@ const cacheStorage = {
|
|||
error: undefined
|
||||
};
|
||||
|
||||
// Not all platforms support getBytesInUse
|
||||
if ( storageLocal.getBytesInUse instanceof Function ) {
|
||||
cacheStorage.getBytesInUse = function(...args) {
|
||||
return storageLocal.getBytesInUse(...args).catch(reason => {
|
||||
console.log(reason);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
// Reassign API entries to that of indexedDB-based ones
|
||||
const selectIDB = async function() {
|
||||
let db;
|
||||
|
|
Loading…
Reference in New Issue