Fix + keep same format between dates and folder explorer

This commit is contained in:
Guillaume Wuip 2014-11-01 21:14:37 +01:00
parent 2607046cd5
commit b603bbfc72

View file

@ -40,15 +40,19 @@
*/
var readDir = function (dirPath, callback) {
fs.readdir(dirPath, function (err, list) {
var dir = [];
if (!dirPath || typeof dirPath !== 'string') {
callback("dirPath must be a string");
} else {
fs.readdir(dirPath, function (err, list) {
var dir = [];
list.forEach(function (item) {
dir.push(readNode(path.join(dirPath, item)));
list.forEach(function (item) {
dir.push(readNode(path.join(dirPath, item)));
});
callback(null, dir);
});
callback(null, dir);
});
}
};
@ -129,7 +133,7 @@
readDir(path, function (err, dir) {
if (err) {
res.status(500).end();
res.status(400).end();
} else {
res.status(200).json(dir);
}
@ -172,7 +176,12 @@
dates.forEach(function (date) {
result.push({
date : date,
files : logWriter.history.dates[date]
files : logWriter.history.dates[date].map(function (item) {
return {
name : path.basename(item),
path : item
};
})
});
});