From 498913b2cac212191f053acd45938002aed11b23 Mon Sep 17 00:00:00 2001
From: Edward Rudd <urkle@outoforder.cc>
Date: Wed, 20 Aug 2014 20:13:57 +0000
Subject: [PATCH] rework how paths are stored so they are relative to the mount root in the structures
---
client/library/humble_cloud.js | 30 ++++++++++++++++++++----------
1 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/client/library/humble_cloud.js b/client/library/humble_cloud.js
index 8cb3bb5..ef90168 100644
--- a/client/library/humble_cloud.js
+++ b/client/library/humble_cloud.js
@@ -63,23 +63,27 @@
}
};
- var check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));
+ var check = FS.readdir(mount.mountpoint).filter(isRealDir);
while (check.length) {
var path = check.pop();
var stat;
+ var abs_path = PATH.join2(mount.mountpoint, path);
try {
- stat = FS.stat(path);
+ stat = FS.stat(abs_path);
} catch (e) {
return callback(e);
}
if (FS.isDir(stat.mode)) {
- check.push.apply(check, FS.readdir(path).filter(isRealDir).map(toAbsolute(path)));
+ check.push.apply(check, FS.readdir(abs_path).filter(isRealDir).map(toAbsolute(path)));
}
- entries[path] = { timestamp: stat.mtime };
+ entries[abs_path] = {
+ timestamp: stat.mtime,
+ path: path
+ };
}
return callback(null, { type: 'local', entries: entries });
@@ -101,20 +105,26 @@
// remove the empty directory from the beginning
if (parts[0] == '') parts.shift();
+ var prefix = '';
parts.forEach(function(e) {
- var p = toAbsolute(e);
- if (!(p in entries)) {
- entries[p] = {
+ var p = PATH.join2(prefix, e),
+ abs = toAbsolute(p);
+ if (!(abs in entries)) {
+ entries[abs] = {
+ path: p,
timestamp: timestamp
- }
+ };
}
+ prefix = p;
})
}
- entries[toAbsolute(f.path)] = {
+ var p = toAbsolute(f.path);
+ entries[p] = {
url: (f.url.substr(0, 1) == '/') ? HUMBLE_CLOUD.remoteAPIEndpoint + f.url : f.url,
+ path: f.path.trim('/'),
timestamp: timestamp,
size: f.size
- }
+ };
}
return callback(null, { type: 'remote', entries: entries } );
}, function(e) {
--
Gitblit v1.9.3