diff --git a/cloudcmd.js b/cloudcmd.js index e6e3a45d..fb14b00e 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -251,12 +251,12 @@ function getContent(name, callback) { fs.stat(name, function(error, stat) { - var isFile, - isDir = stat && stat.isDirectory(), - func = Util.retExec(callback); + var getDirContent = main.commander.getDirContent, + isDir = stat && stat.isDirectory(), + func = Util.retExec(callback); if (!error && isDir) - main.commander.getDirContent(name, callback); + getDirContent(name, callback); else func(error, null, !isDir); }); diff --git a/lib/server/rest.js b/lib/server/rest.js index 35a164d7..565c6891 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -344,13 +344,10 @@ var getDirContent = main.commander.getDirContent, isDir = stat && stat.isDirectory(); - if (error) - func(error); + if (isDir && !error) + getDirContent(name, func); else - if (!isDir) - func(null, null, !isDir); - else - getDirContent(name, func); + func(error, null, !isDir); }); break; }