feature(rest) add recursiv copy dir (rimraf -> fs-extra)

This commit is contained in:
coderaiser 2014-02-11 05:05:28 -05:00
parent 14d42af6b5
commit 2802fbd9b4
2 changed files with 14 additions and 11 deletions

View file

@ -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;

View file

@ -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": {