diff --git a/lib/server/rest.js b/lib/server/rest.js index 8b8f3b14..0d5e39c9 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -189,15 +189,8 @@ case 'mv': if (!files.from || !files.to) { callback(body); - - } else if (isRootWin32(files.to)) { - error = getWin32RootMsg('to'); - callback(error); - - } else if (isRootWin32(files.from)) { - error = getWin32RootMsg('from'); - callback(error); - + } else if (isRootAll([files.to, files.from])) { + callback(getWin32RootMsg()); } else { files.from = root(files.from); files.to = root(files.to); @@ -219,14 +212,8 @@ case 'cp': if (!files.from || !files.names || !files.to) { callback(body); - - } else if (isRootWin32(files.to)) { - error = getWin32RootMsg('to'); - callback(error); - - } else if (isRootWin32(files.from)) { - error = getWin32RootMsg('from'); - callback(error); + } else if (isRootAll([files.to, files.from])) { + callback(getWin32RootMsg()); } else { files.from = root(files.from); files.to = root(files.to); @@ -351,11 +338,16 @@ return isWin32 && isRoot && isConfig; } - function getWin32RootMsg(direction) { - var messageRaw = 'Could not copy {{ direction }} root on windows!', - message = rendy(messageRaw, { - direction: direction - }), + function isRootAll(names) { + var is = names.some(function(name) { + return isRootWin32(name); + }); + + return is; + } + + function getWin32RootMsg() { + var message = 'Could not copy from/to root on windows!', error = Error(message); return error;