mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(rest) add recursiv copy dir (rimraf -> fs-extra)
This commit is contained in:
parent
14d42af6b5
commit
2802fbd9b4
2 changed files with 14 additions and 11 deletions
|
|
@ -24,7 +24,7 @@
|
|||
dir = main.dir,
|
||||
diff = main.diff,
|
||||
time = main.time,
|
||||
rimraf = main.require('rimraf'),
|
||||
fse = main.require('fs-extra'),
|
||||
JSONDIR = main.JSONDIR,
|
||||
OK = 200,
|
||||
sendError = main.sendError,
|
||||
|
|
@ -228,7 +228,7 @@
|
|||
|
||||
function onDelete(params, query, callback) {
|
||||
var rmFile = fs.unlink.bind(fs),
|
||||
rmDir = rimraf || fs.rmdir.bind(fs),
|
||||
rmDir = fse && fse.remove.bind(fse) || fs.rmdir.bind(fs),
|
||||
p = params;
|
||||
|
||||
if (query === 'dir')
|
||||
|
|
@ -358,7 +358,7 @@
|
|||
* @param pParams {command, method, body, requrest, response}
|
||||
*/
|
||||
function onPUT(pParams) {
|
||||
var name, data, json, config,
|
||||
var name, data, json, config, callback,
|
||||
ret = main.checkParams(pParams, ['body']);
|
||||
|
||||
if (ret) {
|
||||
|
|
@ -389,18 +389,21 @@
|
|||
break;
|
||||
|
||||
case 'cp':
|
||||
if (!Util.checkObjTrue(lFiles, ['from', 'to']))
|
||||
callback = function(error) {
|
||||
checkSendError(error, pParams, function() {
|
||||
sendMsg(pParams, 'copy', lFiles.to);
|
||||
});
|
||||
};
|
||||
|
||||
if (!Util.checkObjTrue(lFiles, ['from', 'to']))
|
||||
sendError(pParams, p.data);
|
||||
else if (fse)
|
||||
fse.copy(lFiles.from, lFiles.to, callback);
|
||||
else
|
||||
pipe.create({
|
||||
from : lFiles.from,
|
||||
to : lFiles.to,
|
||||
callback : function(pError) {
|
||||
if (pError)
|
||||
sendError(pParams, pError);
|
||||
else
|
||||
sendMsg(pParams, 'copy', lFiles.to);
|
||||
}
|
||||
callback : callback
|
||||
});
|
||||
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
"socket.io": "0.9.16",
|
||||
"express": "3.4.x",
|
||||
"http-auth": "2.1.x",
|
||||
"rimraf": "2.2.x"
|
||||
"fs-extra": "0.8.x"
|
||||
},
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue