mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-21 10:38:26 +00:00
feature(files) readPipe: change arguments order
This commit is contained in:
parent
2114c720a7
commit
44779f0bb1
2 changed files with 33 additions and 41 deletions
|
|
@ -39,36 +39,34 @@
|
|||
|
||||
object.readPipe = readPipe;
|
||||
|
||||
function readPipe(params) {
|
||||
var name, names, lenght,
|
||||
p = params,
|
||||
options = {
|
||||
gzip : p.gzip,
|
||||
notEnd : true
|
||||
};
|
||||
function readPipe(names, write, options, callback) {
|
||||
var name, lenght;
|
||||
|
||||
if (p.names) {
|
||||
names = p.names.slice();
|
||||
lenght = p.names.length;
|
||||
if (!callback) {
|
||||
callback = options;
|
||||
options = {
|
||||
gzip : false
|
||||
};
|
||||
}
|
||||
|
||||
options.notEnd = true;
|
||||
|
||||
if (names) {
|
||||
lenght = names.length;
|
||||
names = names.slice();
|
||||
}
|
||||
|
||||
if (!lenght) {
|
||||
p.write.end();
|
||||
Util.exec(p.callback);
|
||||
write.end();
|
||||
callback();
|
||||
} else {
|
||||
name = names.shift();
|
||||
|
||||
pipe.create(name, p.write, options, function(error) {
|
||||
pipe.create(name, write, options, function(error) {
|
||||
if (error)
|
||||
Util.exec(p.callback, error);
|
||||
callback(error);
|
||||
else
|
||||
readPipe({
|
||||
dir : p.dir,
|
||||
names : names,
|
||||
write : p.write,
|
||||
gzip : p.gzip,
|
||||
callback : p.callback
|
||||
});
|
||||
readPipe(names, write, options, callback);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,26 +47,20 @@
|
|||
|
||||
stream = isGzip ? gzip : res;
|
||||
|
||||
files.readPipe({
|
||||
names : names,
|
||||
write : stream,
|
||||
callback : function(error) {
|
||||
var errorStr;
|
||||
|
||||
if (error)
|
||||
if (!res.headersSent)
|
||||
main.sendError({
|
||||
request : req,
|
||||
response : res,
|
||||
name : path
|
||||
}, error);
|
||||
else {
|
||||
Util.log(error);
|
||||
errorStr = error.toString();
|
||||
stream.end(errorStr);
|
||||
}
|
||||
}
|
||||
});
|
||||
files.readPipe(names, stream, function(error) {
|
||||
if (error)
|
||||
if (!res.headersSent)
|
||||
main.sendError({
|
||||
request : req,
|
||||
response : res,
|
||||
name : path
|
||||
}, error);
|
||||
else {
|
||||
Util.log(error);
|
||||
stream.end(error.message);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/*
|
||||
* pipe should be setted up after
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue