чтобы в log не было много записей listObjects error

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/nodeJSProjects@64971 954022d7-b5bf-4e40-9824-e11837661b57
This commit is contained in:
Sergey.Konovalov
2015-09-25 15:41:31 +00:00
committed by Alexander.Trofimov
parent 1b2e53376d
commit 5f019d5557

View File

@ -75,17 +75,27 @@ function* walkDir(fsPath, results, optNoSubDir) {
}
}
}
exports.listObjects = function(fsPath, optNoSubDir) {
return new Promise(function(resolve, reject) {
exports.listObjects = function (fsPath, optNoSubDir) {
return new Promise(function (resolve, reject) {
exports.spawn(function* () {
try {
var list;
var stats = yield fsStat(fsPath);
if (stats.isDirectory()) {
list = [];
yield* walkDir(fsPath, list, optNoSubDir);
var stats;
try {
stats = yield fsStat(fsPath);
} catch (e) {
//exception if fsPath not exist
stats = null;
}
if (stats) {
if (stats.isDirectory()) {
list = [];
yield* walkDir(fsPath, list, optNoSubDir);
} else {
list = [fsPath];
}
} else {
list = [fsPath];
list = [];
}
resolve(list);
} catch (err) {