feature(rest) onPUT: add mellow.convertPath

This commit is contained in:
coderaiser 2014-06-23 02:52:33 -04:00
parent b16c910995
commit 35f88f1e20

View file

@ -286,9 +286,11 @@
break;
case 'mv':
if (!Util.checkObjTrue(files, ['from', 'to']) )
if (!files.from || !files.to) {
sendError(params, p.data);
else {
} else {
files.from = mellow.convertPath(files.from);
files.to = mellow.convertPath(files.to);
if (files.names)
data = Util.slice(files.names);
@ -306,9 +308,12 @@
break;
case 'cp':
if (!Util.checkObjTrue(files, ['from', 'names', 'to']))
if (!files.from || !files.names || !files.to) {
sendError(params, p.data);
else {
} else {
files.from = mellow.convertPath(files.from);
files.to = mellow.convertPath(files.to);
files.namesAll = Util.slice(files.names);
copyFiles(files, flop.copy, function(error) {
if (error)
@ -323,8 +328,11 @@
if (!files.from) {
sendError(params, p.data);
} else {
from = files.from;
to = files.to || from + '.zip';
from = mellow.convertPath(files.from);
to = mellow.convertPath(files.to);
if (!to)
to = from + '.zip';
pack.gzip(from, to, function(error) {
var name = path.basename(files.from);
@ -341,8 +349,11 @@
if (!files.from) {
sendError(params, p.data);
} else {
from = files.from;
to = files.to || Util.rmStrOnce(files.from, ['.zip', '.gzip']);
from = mellow.convertPath(files.from);
to = mellow.convertPath(files.to);
if (!to)
to = Util.rmStrOnce(files.from, ['.zip', '.gzip']);
pack.gunzip(from, to, function(error) {
var name = path.basename(files.from);