This commit is contained in:
gorhill 2017-09-21 08:59:40 -04:00
parent 0130e2b462
commit a264975c9c
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 14 additions and 6 deletions

View File

@ -112,13 +112,13 @@ vAPI.cacheStorage = (function() {
var req = indexedDB.open(STORAGE_NAME, 1); var req = indexedDB.open(STORAGE_NAME, 1);
req.onupgradeneeded = function(ev) { req.onupgradeneeded = function(ev) {
db = ev.target.result; db = ev.target.result;
db.onerror = genericErrorHandler; db.onerror = db.onabort = genericErrorHandler;
var table = db.createObjectStore(STORAGE_NAME, { keyPath: 'key' }); var table = db.createObjectStore(STORAGE_NAME, { keyPath: 'key' });
table.createIndex('value', 'value', { unique: false }); table.createIndex('value', 'value', { unique: false });
}; };
req.onsuccess = function(ev) { req.onsuccess = function(ev) {
db = ev.target.result; db = ev.target.result;
db.onerror = genericErrorHandler; db.onerror = db.onabort = genericErrorHandler;
processPendings(); processPendings();
}; };
req.onerror = function() { req.onerror = function() {
@ -141,7 +141,9 @@ vAPI.cacheStorage = (function() {
getDb(function(db) { getDb(function(db) {
if ( !db ) { return callback(); } if ( !db ) { return callback(); }
var transaction = db.transaction(STORAGE_NAME); var transaction = db.transaction(STORAGE_NAME);
transaction.oncomplete = transaction.onerror = function() { transaction.oncomplete =
transaction.onerror =
transaction.onabort = function() {
// TODO: remove once storage.local is clean // TODO: remove once storage.local is clean
if ( notfoundKeys.size === 0 ) { if ( notfoundKeys.size === 0 ) {
vAPI.storage.remove(keys); vAPI.storage.remove(keys);
@ -199,7 +201,9 @@ vAPI.cacheStorage = (function() {
if ( !db ) { return callback(); } if ( !db ) { return callback(); }
var output = {}; var output = {};
var transaction = db.transaction(STORAGE_NAME); var transaction = db.transaction(STORAGE_NAME);
transaction.oncomplete = transaction.onerror = function() { transaction.oncomplete =
transaction.onerror =
transaction.onabort = function() {
callback(output); callback(output);
}; };
var table = transaction.objectStore(STORAGE_NAME), var table = transaction.objectStore(STORAGE_NAME),
@ -222,7 +226,9 @@ vAPI.cacheStorage = (function() {
getDb(function(db) { getDb(function(db) {
if ( !db ) { return callback(); } if ( !db ) { return callback(); }
var transaction = db.transaction(STORAGE_NAME, 'readwrite'); var transaction = db.transaction(STORAGE_NAME, 'readwrite');
transaction.oncomplete = transaction.onerror = callback; transaction.oncomplete =
transaction.onerror =
transaction.onabort = callback;
var table = transaction.objectStore(STORAGE_NAME), var table = transaction.objectStore(STORAGE_NAME),
entry = {}; entry = {};
for ( var key of keys ) { for ( var key of keys ) {
@ -242,7 +248,9 @@ vAPI.cacheStorage = (function() {
getDb(function(db) { getDb(function(db) {
if ( !db ) { return callback(); } if ( !db ) { return callback(); }
var transaction = db.transaction(STORAGE_NAME, 'readwrite'); var transaction = db.transaction(STORAGE_NAME, 'readwrite');
transaction.oncomplete = transaction.onerror = callback; transaction.oncomplete =
transaction.onerror =
transaction.onabort = callback;
var table = transaction.objectStore(STORAGE_NAME); var table = transaction.objectStore(STORAGE_NAME);
for ( var key of keys ) { for ( var key of keys ) {
table.delete(key); table.delete(key);