| | |
| | | callback(this.error); |
| | | }; |
| | | }, |
| | | listFilesByScope: function(scope, listCB) { |
| | | CLOUDFS.getDB(function(err, db) { |
| | | if (err) listCB(err); |
| | | |
| | | var transaction = db.transaction([CLOUDFS.DB_STORE_NAME], 'readonly'); |
| | | transaction.onerror = function() { listCB(this.error); }; |
| | | |
| | | var store = transaction.objectStore(CLOUDFS.DB_STORE_NAME); |
| | | var index = store.index('scope'); |
| | | var entries = []; |
| | | |
| | | index.openCursor(IDBKeyRange.only(scope)).onsuccess = function(event) { |
| | | var cursor = event.target.result; |
| | | |
| | | if (!cursor) { |
| | | return listCB(null, entries); |
| | | } |
| | | |
| | | if (FS.isFile(cursor.value.mode)) { |
| | | entries.push(cursor.value.path); |
| | | } |
| | | |
| | | cursor.continue(); |
| | | }; |
| | | }); |
| | | }, |
| | | clearFilesByScope: function(scope, oncomplete) { |
| | | CLOUDFS.getDB(function(err, db) { |
| | | if (err) oncomplete(err); |
| | | |
| | | var transaction = db.transaction([CLOUDFS.DB_STORE_NAME], 'readwrite'); |
| | | transaction.onerror = function() { oncomplete(this.error); }; |
| | | |
| | | var store = transaction.objectStore(CLOUDFS.DB_STORE_NAME); |
| | | var index = store.index('scope'); |
| | | var entries = []; |
| | | |
| | | index.openKeyCursor(IDBKeyRange.only(scope)).onsuccess = function(event) { |
| | | var cursor = event.target.result; |
| | | |
| | | if (cursor) { |
| | | store.delete(cursor.primaryKey); |
| | | |
| | | cursor.continue(); |
| | | } else { |
| | | oncomplete(null); |
| | | } |
| | | }; |
| | | }); |
| | | }, |
| | | // Getting list of entities |
| | | getLocalSet: function(mount, callback) { |
| | | function isRealDir(p) { |