changed statSync to async version

This commit is contained in:
coderaiser 2012-08-01 10:37:52 -04:00
parent 782592a34b
commit 2c89597fc9
2 changed files with 29 additions and 25 deletions

View file

@ -2,7 +2,6 @@
node_js:
#- 0.4 #jshint fails to install (no gzip, jshint test not working out)
- 0.6
- 0.7 # development version of 0.8, may be unstable
- 0.8
notifications:
webhooks:

View file

@ -387,20 +387,8 @@ CloudServer._controller=function(pReq, pRes)
/* Проверяем с папкой ли мы имеем дело */
/* читаем сновные данные о файле */
var lStat;
try{
lStat=Fs.statSync(DirPath);
}catch(error){
console.log(error);
CloudServer.Statuses[DirPath] = 404;
CloudServer.sendResponse('OK',error.toString(),DirPath);
}
/* если это каталог -
* читаем его содержимое
*/
Fs.stat(DirPath, CloudServer._stated);
/* если установлено сжатие
* меняем название html-файла и
* загружаем сжатый html-файл в дальнейшем
@ -414,22 +402,39 @@ CloudServer._controller=function(pReq, pRes)
*/
CloudServer.Responses[CloudServer.INDEX]=pRes;
CloudServer.Statuses[CloudServer.INDEX] = 200;
}
}
};
/*
* Function geted stat information about file
*/
CloudServer._stated = function(pError, pStat){
if(pError){
CloudServer.Statuses[DirPath] = 404;
CloudServer.sendResponse('OK',pError.toString(),DirPath);
return;
}
/*
* если это каталог -
* читаем его содержимое
*/
if(lStat){
if(lStat.isDirectory())
Fs.readdir(DirPath,CloudServer._readDir);
/* отдаём файл */
else if(lStat.isFile()){
Fs.readFile(DirPath,CloudServer.getReadFileFunc(DirPath));
console.log('reading file: '+DirPath);
}
}
if(pStat){
if(pStat.isDirectory())
Fs.readdir(DirPath,CloudServer._readDir);
/* отдаём файл */
else if(pStat.isFile()){
Fs.readFile(DirPath,CloudServer.getReadFileFunc(DirPath));
console.log('reading file: '+DirPath);
}
}
};
/* Функция читает ссылку или выводит информацию об ошибке*/
CloudServer._readDir=function (pError, pFiles)
CloudServer._readDir = function (pError, pFiles)
{
if(!pError)
{