feature(rest) zip, unzip -> pack, unpack

This commit is contained in:
coderaiser 2014-11-01 04:12:42 -04:00
parent 2a6db8c64f
commit 7e28316a22
5 changed files with 22 additions and 22 deletions

View file

@ -498,13 +498,13 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
Util.checkArgs(arguments, ['operation']);
if (operation.pack) {
op = RESTful.zip;
op = RESTful.pack;
nameDir = name + '.tar.gz';
nameFile = name + '.zip';
nameFile = name + '.gz';
} else if (operation.unpack) {
op = RESTful.unzip;
op = RESTful.unpack;
nameDir = Util.rmStrOnce(name, '.tar.gz');
nameFile = Util.rmStrOnce(name, '.zip');
nameFile = Util.rmStrOnce(name, '.gz');
}
Images.showLoad();

View file

@ -95,19 +95,19 @@ var Util, DOM, CloudFunc, CloudCmd;
});
};
this.zip = function(data, callback) {
this.pack = function(data, callback) {
sendRequest({
method : 'PUT',
url : '/zip',
url : '/pack',
data : data,
callback : callback
});
};
this.unzip = function(data, callback) {
this.unpack = function(data, callback) {
sendRequest({
method : 'PUT',
url : '/unzip',
url : '/unpack',
data : data,
callback : callback
});

View file

@ -15,7 +15,7 @@
Util = require(DIR_LIB + 'util'),
pipe = require(DIR + 'pipe');
exports.gzip = function(from, to, callback) {
exports.pack = function(from, to, callback) {
isDir(from, function(is) {
var options = {
gzip: true
@ -29,8 +29,8 @@
isStr = Util.type.string(to);
if (isStr) {
dir = path.dirname(to),
name = path.basename(to, '.zip');
dir = path.dirname(to);
name = path.basename(to);
to = dir + path.sep + name + '.tar.gz';
}
@ -39,7 +39,7 @@
});
};
exports.gunzip = function(from, to, callback) {
exports.unpack = function(from, to, callback) {
var write,
isStr = Util.type.string(from),
check = Util.checkExt,

View file

@ -23,7 +23,7 @@
github = require(DIR + 'github'),
flop = require(DIR + 'flop'),
pack = require(DIR + 'pack'),
packer = require(DIR + 'packer'),
mellow = require(DIR + 'mellow'),
ponse = require(DIR + 'ponse'),
pipe = require(DIR + 'pipe'),
@ -330,7 +330,7 @@
}
break;
case 'zip':
case 'pack':
if (!files.from) {
callback(body);
} else {
@ -339,18 +339,18 @@
if (files.to)
to = mellow.convertPath(files.to);
else
to = from + '.zip';
to = from + '.gz';
pack.gzip(from, to, function(error) {
packer.pack(from, to, function(error) {
var name = path.basename(files.from),
msg = formatMsg('zip', name);
msg = formatMsg('pack', name);
callback(error, msg);
});
}
break;
case 'unzip':
case 'unpack':
if (!files.from) {
callback(body);
} else {
@ -361,9 +361,9 @@
else
to = Util.rmStrOnce(files.from, ['.zip', '.tar.gz', '.gz']);
pack.gunzip(from, to, function(error) {
packer.unpack(from, to, function(error) {
var name = path.basename(files.from),
data = formatMsg('unzip', name);
data = formatMsg('unpack', name);
callback(error, data);
});

View file

@ -11,7 +11,7 @@
Util = require(DIR + 'util'),
flop = require(DIR_SERVER + 'flop'),
pack = require(DIR_SERVER + 'pack'),
packer = require(DIR_SERVER + 'packer'),
pipe = require(DIR_SERVER + 'pipe'),
patch = require('./patch');
@ -42,7 +42,7 @@
break;
case 'unzip':
pack.gunzip(readStream, name, onSave);
packer.unpack(readStream, name, onSave);
break;
case 'patch':