mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 09:07:54 +01:00
Add unlimitedStorage
to Firefox manifest; add timeout to IndexedDB access
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/416 The Chromium version of uBO has declared `unlimitedStorage` since the extension was first published in 2014. Declaring this permission in Firefox brings uBO inline with the Chromium version. I suspect some reported errors could be caused by IndexedDB eviction due to the lack of `unlimitedStorage` permission. Additionally, a timeout has been added when uBO tries to access its indexedDB storage. It's unclear whether this will help with the mentioned related issue though, the root cause is still to be identified.
This commit is contained in:
parent
dbecb71262
commit
34a138e3ef
2 changed files with 19 additions and 5 deletions
|
@ -74,6 +74,7 @@
|
|||
"privacy",
|
||||
"storage",
|
||||
"tabs",
|
||||
"unlimitedStorage",
|
||||
"webNavigation",
|
||||
"webRequest",
|
||||
"webRequestBlocking",
|
||||
|
|
|
@ -226,19 +226,30 @@
|
|||
table.createIndex('value', 'value', { unique: false });
|
||||
};
|
||||
req.onsuccess = function(ev) {
|
||||
if ( resolve === undefined ) { return; }
|
||||
req = undefined;
|
||||
db = ev.target.result;
|
||||
db.onerror = db.onabort = genericErrorHandler;
|
||||
dbPromise = undefined;
|
||||
resolve(db);
|
||||
resolve = undefined;
|
||||
};
|
||||
req.onerror = req.onblocked = function() {
|
||||
if ( resolve === undefined ) { return; }
|
||||
req = undefined;
|
||||
console.log(this.error);
|
||||
db = null;
|
||||
dbPromise = undefined;
|
||||
resolve(null);
|
||||
resolve = undefined;
|
||||
};
|
||||
setTimeout(( ) => {
|
||||
if ( resolve === undefined ) { return; }
|
||||
db = null;
|
||||
dbPromise = undefined;
|
||||
resolve(null);
|
||||
resolve = undefined;
|
||||
}, 5000);
|
||||
});
|
||||
return dbPromise;
|
||||
};
|
||||
|
@ -246,8 +257,8 @@
|
|||
const getFromDb = function(keys, keyvalStore, callback) {
|
||||
if ( typeof callback !== 'function' ) { return; }
|
||||
if ( keys.length === 0 ) { return callback(keyvalStore); }
|
||||
let promises = [];
|
||||
let gotOne = function() {
|
||||
const promises = [];
|
||||
const gotOne = function() {
|
||||
if ( typeof this.result !== 'object' ) { return; }
|
||||
keyvalStore[this.result.key] = this.result.value;
|
||||
if ( this.result.value instanceof Blob === false ) { return; }
|
||||
|
@ -262,7 +273,7 @@
|
|||
};
|
||||
getDb().then(db => {
|
||||
if ( !db ) { return callback(); }
|
||||
const transaction = db.transaction(STORAGE_NAME);
|
||||
const transaction = db.transaction(STORAGE_NAME, 'readonly');
|
||||
transaction.oncomplete =
|
||||
transaction.onerror =
|
||||
transaction.onabort = ( ) => {
|
||||
|
@ -272,11 +283,13 @@
|
|||
};
|
||||
const table = transaction.objectStore(STORAGE_NAME);
|
||||
for ( const key of keys ) {
|
||||
let req = table.get(key);
|
||||
const req = table.get(key);
|
||||
req.onsuccess = gotOne;
|
||||
req.onerror = noopfn;
|
||||
req = undefined;
|
||||
}
|
||||
}).catch(reason => {
|
||||
console.info(`cacheStorage.getFromDb() failed: ${reason}`);
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue