mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-26 09:24:07 +00:00
added ability to copy files
This commit is contained in:
parent
b0a75540b7
commit
fbae7813e4
6 changed files with 73 additions and 31 deletions
|
|
@ -132,7 +132,6 @@
|
|||
var lWriteStream = fs.createWriteStream(p.name);
|
||||
|
||||
lWriteStream.on('error', function(pError){
|
||||
console.log(pError);
|
||||
main.sendError(pParams, pError);
|
||||
});
|
||||
|
||||
|
|
@ -243,13 +242,14 @@
|
|||
main.sendError(pParams, pError);
|
||||
});
|
||||
else
|
||||
main.sendError(pParams, p.data);
|
||||
main.sendError(pParams, p.data);
|
||||
break;
|
||||
|
||||
case 'cp':
|
||||
if(lFiles){
|
||||
var lReadStream = fs.createReadStream(lFiles.from),
|
||||
lWriteStream = fs.createWriteStream(lFiles.to),
|
||||
if( Util.checkObjTrue(lFiles, ['from', 'to']) ){
|
||||
var l = lFiles,
|
||||
lReadStream = fs.createReadStream(l.from),
|
||||
lWriteStream = fs.createWriteStream(l.to),
|
||||
lError = function(pError){
|
||||
main.sendError(pParams, pError);
|
||||
};
|
||||
|
|
@ -258,12 +258,14 @@
|
|||
lWriteStream.on('error', lError);
|
||||
lReadStream.on('error', lError);
|
||||
|
||||
lWriteStream.on('end', function(){
|
||||
main.sendResponse(pParams, 'copied: ' + p.name);
|
||||
lReadStream.on('end', function(){
|
||||
main.sendResponse(pParams, 'copied to: ' + l.to);
|
||||
});
|
||||
|
||||
lReadStream.pipe(lWriteStream);
|
||||
}
|
||||
else
|
||||
main.sendError(pParams, p.data);
|
||||
break;
|
||||
default:
|
||||
send(pParams);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue