diff --git a/lib/server/rest.js b/lib/server/rest.js index 17814db5..378cae5a 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -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);