mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-24 03:05:41 +00:00
refactor(rest) onFS delete: Util.call -> bind
This commit is contained in:
parent
e0b56bc322
commit
ebcaf450c5
1 changed files with 14 additions and 25 deletions
|
|
@ -204,8 +204,8 @@
|
|||
|
||||
case 'DELETE':
|
||||
if (lQuery === 'dir')
|
||||
fs.rmdir(p.name, function(pError) {
|
||||
checkSendError(pError, params, function() {
|
||||
fs.rmdir(p.name, function(error) {
|
||||
checkSendError(error, params, function() {
|
||||
sendMsg(params, 'delete', p.name);
|
||||
});
|
||||
});
|
||||
|
|
@ -218,28 +218,19 @@
|
|||
log = Util.log.bind(Util),
|
||||
lAssync = 0;
|
||||
|
||||
function stat(pStat) {
|
||||
var p, d,
|
||||
ret = Util.checkObjTrue(pStat, 'params') &&
|
||||
Util.checkObjTrue(pStat.params, 'name');
|
||||
function onStat(name, error, stat) {
|
||||
++lAssync;
|
||||
|
||||
if (ret) {
|
||||
p = pStat,
|
||||
d = p.params;
|
||||
checkSendError(error, params, function() {
|
||||
if (stat.isDirectory())
|
||||
fs.rmdir(name, log);
|
||||
|
||||
++lAssync;
|
||||
|
||||
checkSendError(p.error, params, function() {
|
||||
if (p.data.isDirectory())
|
||||
fs.rmdir(d.name, log);
|
||||
|
||||
else if (p.data.isFile())
|
||||
fs.unlink(d.name, log);
|
||||
});
|
||||
|
||||
if (lAssync === n && !p.error)
|
||||
sendMsg(params, 'delete', pBody);
|
||||
}
|
||||
else if (stat.isFile())
|
||||
fs.unlink(name, log);
|
||||
});
|
||||
|
||||
if (lAssync === n && !error)
|
||||
sendMsg(params, 'delete', pBody);
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i ++) {
|
||||
|
|
@ -247,9 +238,7 @@
|
|||
|
||||
Util.log(name);
|
||||
|
||||
fs.stat(name, Util.call(stat, {
|
||||
name: name
|
||||
}));
|
||||
fs.stat(name, onStat.bind(null, name));
|
||||
}
|
||||
});
|
||||
} else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue