refactor(put) onPut

This commit is contained in:
coderaiser 2014-06-22 09:58:19 -04:00
parent 5b65baf15f
commit 4994b1b86a

View file

@ -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':