emscripten Humble Cloud interface
Edward Rudd
2014-10-14 ddc9352324fc18d45e29ef9e80990c43e5fe3d7c

tag type of entity for LocalSet

1 files modified
31 ■■■■■ changed files
client/library/library_cloudfs.js 31 ●●●●● patch | view | raw | blame | history
client/library/library_cloudfs.js
@@ -196,6 +196,7 @@
                var path = check.pop(),
                    stat,
                    keep = true,
                    is_dir = false,
                    abs_path = PATH.join2(mount.mountpoint, path);
                try {
@@ -206,6 +207,7 @@
                if (FS.isDir(stat.mode)) {
                    check.push.apply(check, FS.readdir(abs_path).filter(isRealDir).map(toAbsolute(path)));
                    is_dir = true;
                } else if (shouldFilter) {
                    keep = checkPath(path);
                }
@@ -213,13 +215,40 @@
                if (keep) {
                    entries[abs_path] = {
                        timestamp: stat.mtime,
                        path: path
                        path: path,
                        type: is_dir ? 'dir' : 'file'
                    };
                }
            }
            return callback(null, { type: 'local', entries: entries });
        },
        getIDBSet: function(mount, callback) {
          var entries = {},
              toAbsolute = function(p) { return PATH.join2(mount.mountpoint, p); };
          CLOUDFS.getDB(function(err, db) {
            if (err) return callback(err);
            var transaction = db.transaction([CLOUDFS.DB_STORE_NAME], 'readonly');
            transaction.onerror = function() { callback(this.error); };
            var store = transaction.objectStore(CLOUDFS.DB_STORE_NAME);
            var index = store.index('scope');
            index.openKeyCursor(IDBKeyRange.only(mount.opts.scope)).onsuccess = function(event) {
              var cursor = event.target.result;
              if (!cursor) {
                return callback(null, { type: 'idb', db: db, entries: entries });
              }
              entries[cursor.primaryKey] = { timestamp: cursor.key };
              cursor.continue();
            };
          });
        },
        getRemoteSet: function(mount, callback) {
          mount.opts.provider.allFiles(mount.opts.cloud, function(data) {
            var entries = {},