mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-25 00:50:59 +00:00
refactor(commander) getFilesStat
This commit is contained in:
parent
3231833e67
commit
c0911f5181
1 changed files with 13 additions and 14 deletions
|
|
@ -72,7 +72,7 @@
|
|||
stats : stats,
|
||||
};
|
||||
|
||||
fs.stat(name, Util.call(getFilesStat, fileParams));
|
||||
fs.stat(name, getFilesStat.bind(null, fileParams));
|
||||
}
|
||||
else
|
||||
fillJSON(filesData);
|
||||
|
|
@ -83,24 +83,23 @@
|
|||
* async getting file states
|
||||
* and putting it to lStats object
|
||||
*/
|
||||
function getFilesStat(pParams) {
|
||||
var lRet = checkParams(pParams);
|
||||
lRet = lRet && Util.checkObjTrue(pParams.params,
|
||||
['callback', 'stats', 'name', 'count']);
|
||||
function getFilesStat(params, error, stat) {
|
||||
var n, keys, p = params;
|
||||
|
||||
if (lRet) {
|
||||
var p = pParams,
|
||||
c = p.params;
|
||||
|
||||
c.stats[c.name] = !p.error ? p.data : {
|
||||
if (!error)
|
||||
p.stats[p.name] = stat;
|
||||
else
|
||||
p.stats[p.name] = {
|
||||
'mode' : 0,
|
||||
'size' : 0,
|
||||
'isDirectory' : Util.retFalse
|
||||
};
|
||||
|
||||
if (c.count === Object.keys(c.stats).length)
|
||||
Util.exec(c.callback);
|
||||
}
|
||||
|
||||
keys = Object.keys(p.stats);
|
||||
n = keys.length;
|
||||
|
||||
if (p.count === n)
|
||||
Util.exec(p.callback);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue