mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
changed statSync to async version
This commit is contained in:
parent
782592a34b
commit
2c89597fc9
2 changed files with 29 additions and 25 deletions
|
|
@ -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:
|
||||
|
|
|
|||
53
server.js
53
server.js
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue