feature(rest) add getWin32RootMsg

This commit is contained in:
coderaiser 2014-07-02 06:36:19 -04:00
parent f79001b972
commit 84e40e95f8

View file

@ -268,8 +268,6 @@
*/
function onPUT(params) {
var p, cmd, files, name, json, config, data, from, to,
WIN32_ROOT_MSG = 'Could not copy to root on windows!',
ret = main.checkParams(params, ['body']);
if (ret) {
@ -294,7 +292,9 @@
if (!files.from || !files.to) {
sendError(params, p.data);
} else if (isRootWin32(files.to)) {
sendError(params, WIN32_ROOT_MSG);
sendError(params, getWin32RooMsg('to'));
} else if (isRootWin32(files.from)) {
sendError(params, getWin32RooMsg('from'));
} else {
files.from = mellow.convertPath(files.from);
files.to = mellow.convertPath(files.to);
@ -318,7 +318,9 @@
if (!files.from || !files.names || !files.to) {
sendError(params, p.data);
} else if (isRootWin32(files.to)) {
sendError(params, WIN32_ROOT_MSG);
sendError(params, getWin32RooMsg('to'));
} else if (isRootWin32(files.from)) {
sendError(params, getWin32RooMsg('from'));
} else {
files.from = mellow.convertPath(files.from);
files.to = mellow.convertPath(files.to);
@ -450,6 +452,15 @@
return isWin32 && isRoot;
}
function getWin32RooMsg(direction) {
var messageRaw = 'Could not copy {{ direction }} root on windows!',
message = Util.render(messageRaw, {
direction: direction
});
return message;
}
function sendMsg(sendParam, msgParam, dataParam, status) {
var msg, data,
isObj = Util.isObject(dataParam);