mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
refactor(rest) add isRootAll
This commit is contained in:
parent
394314dd3d
commit
83e2a187de
1 changed files with 14 additions and 22 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue