Fix whitespace in localfilesystem

This commit is contained in:
Nick O'Leary 2017-01-08 23:01:28 +00:00
parent c8d6693fba
commit f0a4ea099c
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
1 changed files with 48 additions and 48 deletions

View File

@ -333,56 +333,56 @@ var localfilesystem = {
var root = fspath.join(libDir,type);
var rootPath = fspath.join(libDir,type,path);
// don't create the folder if it does not exist - we are only reading....
return nodeFn.call(fs.lstat, rootPath).then(function(stats) {
if (stats.isFile()) {
return getFileBody(root,path);
}
if (path.substr(-1) == '/') {
path = path.substr(0,path.length-1);
}
return nodeFn.call(fs.readdir, rootPath).then(function(fns) {
var dirs = [];
var files = [];
fns.sort().filter(function(fn) {
var fullPath = fspath.join(path,fn);
var absoluteFullPath = fspath.join(root,fullPath);
if (fn[0] != ".") {
var stats = fs.lstatSync(absoluteFullPath);
if (stats.isDirectory()) {
dirs.push(fn);
} else {
var meta = getFileMeta(root,fullPath);
meta.fn = fn;
files.push(meta);
}
}
});
return dirs.concat(files);
});
}).otherwise(function(err) {
// if path is empty, then assume it was a folder, return empty
if (path === ""){
return [];
}
// don't create the folder if it does not exist - we are only reading....
return nodeFn.call(fs.lstat, rootPath).then(function(stats) {
if (stats.isFile()) {
return getFileBody(root,path);
}
if (path.substr(-1) == '/') {
path = path.substr(0,path.length-1);
}
return nodeFn.call(fs.readdir, rootPath).then(function(fns) {
var dirs = [];
var files = [];
fns.sort().filter(function(fn) {
var fullPath = fspath.join(path,fn);
var absoluteFullPath = fspath.join(root,fullPath);
if (fn[0] != ".") {
var stats = fs.lstatSync(absoluteFullPath);
if (stats.isDirectory()) {
dirs.push(fn);
} else {
var meta = getFileMeta(root,fullPath);
meta.fn = fn;
files.push(meta);
}
}
});
return dirs.concat(files);
});
}).otherwise(function(err) {
// if path is empty, then assume it was a folder, return empty
if (path === ""){
return [];
}
// if path ends with slash, it was a folder
// so return empty
if (path.substr(-1) == '/') {
return [];
}
// if path ends with slash, it was a folder
// so return empty
if (path.substr(-1) == '/') {
return [];
}
// else path was specified, but did not exist,
// check for path.json as an alternative if flows
if (type === "flows" && !/\.json$/.test(path)) {
return localfilesystem.getLibraryEntry(type,path+".json")
.otherwise(function(e) {
throw err;
});
} else {
throw err;
}
});
// else path was specified, but did not exist,
// check for path.json as an alternative if flows
if (type === "flows" && !/\.json$/.test(path)) {
return localfilesystem.getLibraryEntry(type,path+".json")
.otherwise(function(e) {
throw err;
});
} else {
throw err;
}
});
},
saveLibraryEntry: function(type,path,meta,body) {