mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
refactor(put) onPut
This commit is contained in:
parent
5b65baf15f
commit
4994b1b86a
1 changed files with 12 additions and 26 deletions
|
|
@ -19,30 +19,23 @@
|
|||
|
||||
function onPut(name, query, readStream, callback) {
|
||||
var func = Util.exec.ret(callback),
|
||||
baseName = path.basename(name);
|
||||
baseName = path.basename(name),
|
||||
onDone = function(msg, error) {
|
||||
if (!error)
|
||||
msg = CloudFunc.formatMsg(msg, baseName);
|
||||
|
||||
func(error, msg);
|
||||
},
|
||||
onSave = Util.exec.with(onDone, 'save'),
|
||||
OnMakeDir = Util.exec.with(onDone, 'make dir');
|
||||
|
||||
switch(query) {
|
||||
default:
|
||||
pipe.create(readStream, name, function(error) {
|
||||
var msg;
|
||||
|
||||
if (!error)
|
||||
msg = CloudFunc.formatMsg('save', baseName);
|
||||
|
||||
func(error, msg);
|
||||
});
|
||||
pipe.create(readStream, name, onSave);
|
||||
break;
|
||||
|
||||
case 'dir':
|
||||
flop.create(name, 'dir', function(error) {
|
||||
var msg;
|
||||
|
||||
if (!error)
|
||||
msg = CloudFunc.formatMsg('make dir', name);
|
||||
|
||||
func(error, msg);
|
||||
});
|
||||
|
||||
flop.create(name, 'dir', OnMakeDir);
|
||||
break;
|
||||
|
||||
case 'file':
|
||||
|
|
@ -50,14 +43,7 @@
|
|||
break;
|
||||
|
||||
case 'unzip':
|
||||
pack.gunzip(readStream, name, function(error) {
|
||||
var msg;
|
||||
|
||||
if (!error)
|
||||
msg = CloudFunc.formatMsg('save (unzip)', baseName);
|
||||
|
||||
func(error, msg);
|
||||
});
|
||||
pack.gunzip(readStream, name, onSave);
|
||||
break;
|
||||
|
||||
case 'patch':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue