From 4ee52ebe2f2059e012dfad4189d7bd1666a18f80 Mon Sep 17 00:00:00 2001
From: Edward Rudd <urkle@outoforder.cc>
Date: Tue, 14 Oct 2014 12:09:03 +0000
Subject: [PATCH] extract populateDirs functionality to separate method
---
client/library/library_cloudfs.js | 46 +++++++++++++++++++++++++---------------------
1 files changed, 25 insertions(+), 21 deletions(-)
diff --git a/client/library/library_cloudfs.js b/client/library/library_cloudfs.js
index e9146df..31bb111 100644
--- a/client/library/library_cloudfs.js
+++ b/client/library/library_cloudfs.js
@@ -130,6 +130,30 @@
return false;
}
},
+ populateDirs: function(entries, f, toAbsolute) {
+ if (f.path.indexOf('/') !== -1) {
+ // we have folders.. stuff them in the list
+ var parts = f.path.split('/'),
+ prefix = '';
+ // remove the "file" from the end
+ parts.pop();
+ // remove the empty directory from the beginning
+ if (parts[0] == '') parts.shift();
+
+ parts.forEach(function(e) {
+ var p = prefix.length ? PATH.join2(prefix, e) : e,
+ abs = toAbsolute(p);
+ if (!(abs in entries)) {
+ entries[abs] = {
+ path: p,
+ type: 'dir',
+ timestamp: f.timestamp
+ };
+ }
+ prefix = p;
+ });
+ }
+ },
// Getting list of entities
getLocalSet: function(mount, callback) {
function isRealDir(p) {
@@ -203,28 +227,8 @@
for(var k in data) {
var f = data[k];
- if (f.path.indexOf('/') !== -1) {
- // we have folders.. stuff them in the list
- var parts = f.path.split('/'),
- prefix = '';
- // remove the "file" from the end
- parts.pop();
- // remove the empty directory from the beginning
- if (parts[0] == '') parts.shift();
+ CLOUDFS.populateDirs(entries, f, toAbsolute);
- parts.forEach(function(e) {
- var p = prefix.length ? PATH.join2(prefix, e) : e,
- abs = toAbsolute(p);
- if (!(abs in entries)) {
- entries[abs] = {
- path: p,
- type: 'dir',
- timestamp: f.timestamp
- };
- }
- prefix = p;
- });
- }
var p = toAbsolute(f.path);
entries[p] = {
url: f.url,
--
Gitblit v1.9.3