| | |
| | | return { path: path.path, scope: path.scope, key: path.scope + ':' + path.path }; |
| | | } |
| | | }, |
| | | // deletes all entries for the specified scope |
| | | clearCacheByScope: function(scope, oncomplete) { |
| | | HUMBLE_API.getDB(function(err, db) { |
| | | if (err) return oncomplete(err); |
| | | |
| | | var transaction = db.transaction([HUMBLE_API.DB_ASYNC_CACHE_STORE], 'readwrite'); |
| | | transaction.onerror = function() { oncomplete(this.error); }; |
| | | |
| | | var store = transaction.objectStore(HUMBLE_API.DB_ASYNC_CACHE_STORE); |
| | | var index = store.index('scope'); |
| | | |
| | | index.openKeyCursor(IDBKeyRange.only(scope)).onsuccess = function(e) { |
| | | var cursor = event.target.result; |
| | | |
| | | if (cursor) { |
| | | store.delete(cursor.primaryKey); |
| | | |
| | | cursor.continue(); |
| | | } else { |
| | | oncomplete(null); |
| | | } |
| | | }; |
| | | }); |
| | | }, |
| | | storeToCache: function(path, byteArray, ondone) { |
| | | if (path === null) { |
| | | return ondone(null); |