From ddc9352324fc18d45e29ef9e80990c43e5fe3d7c Mon Sep 17 00:00:00 2001
From: Edward Rudd <urkle@outoforder.cc>
Date: Tue, 14 Oct 2014 12:09:23 +0000
Subject: [PATCH] tag type of entity for LocalSet
---
client/library/library_cloudfs.js | 31 ++++++++++++++++++++++++++++++-
1 files changed, 30 insertions(+), 1 deletions(-)
diff --git a/client/library/library_cloudfs.js b/client/library/library_cloudfs.js
index 31bb111..8c4ef67 100644
--- a/client/library/library_cloudfs.js
+++ b/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 = {},
--
Gitblit v1.9.3