diff --git a/lib/server/rest.js b/lib/server/rest.js index ea2c7ebf..4af255d1 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -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);