Copy files to a shared folder instead of moving them
This commit is contained in:
parent
0a7adb3e88
commit
047a4a3ab4
@ -281,6 +281,10 @@ define([
|
|||||||
var resolved = _resolvePaths(Env, data.paths);
|
var resolved = _resolvePaths(Env, data.paths);
|
||||||
var newResolved = _resolvePath(Env, data.newPath);
|
var newResolved = _resolvePath(Env, data.newPath);
|
||||||
|
|
||||||
|
// NOTE: we can only copy when moving from one drive to another. We don't want
|
||||||
|
// duplicates in the same drive
|
||||||
|
var copy = data.copy;
|
||||||
|
|
||||||
if (!newResolved.userObject.isFolder(newResolved.path)) { return void cb(); }
|
if (!newResolved.userObject.isFolder(newResolved.path)) { return void cb(); }
|
||||||
|
|
||||||
nThen(function (waitFor) {
|
nThen(function (waitFor) {
|
||||||
@ -305,6 +309,8 @@ define([
|
|||||||
Array.prototype.push.apply(ownedPads, _owned);
|
Array.prototype.push.apply(ownedPads, _owned);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (copy) { return; }
|
||||||
|
|
||||||
if (resolved.main.length) {
|
if (resolved.main.length) {
|
||||||
var rootPath = resolved.main[0].slice();
|
var rootPath = resolved.main[0].slice();
|
||||||
rootPath.pop();
|
rootPath.pop();
|
||||||
@ -338,6 +344,8 @@ define([
|
|||||||
uoTo.copyFromOtherDrive(newResolved.path, obj.el, obj.data, obj.key);
|
uoTo.copyFromOtherDrive(newResolved.path, obj.el, obj.data, obj.key);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (copy) { return; }
|
||||||
|
|
||||||
// Remove the elements from the old location (without unpinning)
|
// Remove the elements from the old location (without unpinning)
|
||||||
uoFrom.delete(paths, waitFor());
|
uoFrom.delete(paths, waitFor());
|
||||||
}
|
}
|
||||||
@ -791,12 +799,13 @@ define([
|
|||||||
}
|
}
|
||||||
}, cb);
|
}, cb);
|
||||||
};
|
};
|
||||||
var moveInner = function (Env, paths, newPath, cb) {
|
var moveInner = function (Env, paths, newPath, cb, copy) {
|
||||||
return void Env.sframeChan.query("Q_DRIVE_USEROBJECT", {
|
return void Env.sframeChan.query("Q_DRIVE_USEROBJECT", {
|
||||||
cmd: "move",
|
cmd: "move",
|
||||||
data: {
|
data: {
|
||||||
paths: paths,
|
paths: paths,
|
||||||
newPath: newPath
|
newPath: newPath,
|
||||||
|
copy: copy
|
||||||
}
|
}
|
||||||
}, cb);
|
}, cb);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1208,18 +1208,14 @@ define([
|
|||||||
}
|
}
|
||||||
return manager.getTitle(file);
|
return manager.getTitle(file);
|
||||||
};
|
};
|
||||||
// manager.moveElements is able to move several paths to a new location, including
|
// moveElements is able to move several paths to a new location
|
||||||
// the Trash or the "Unsorted files" folder
|
var moveElements = function (paths, newPath, copy, cb) {
|
||||||
var moveElements = function (paths, newPath, force, cb) {
|
|
||||||
if (!APP.editable) { return; }
|
if (!APP.editable) { return; }
|
||||||
var andThenMove = function () {
|
|
||||||
manager.move(paths, newPath, cb);
|
|
||||||
};
|
|
||||||
// Cancel drag&drop from TRASH to TRASH
|
// Cancel drag&drop from TRASH to TRASH
|
||||||
if (manager.isPathIn(newPath, [TRASH]) && paths.length && paths[0][0] === TRASH) {
|
if (manager.isPathIn(newPath, [TRASH]) && paths.length && paths[0][0] === TRASH) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
andThenMove();
|
manager.move(paths, newPath, cb, copy);
|
||||||
};
|
};
|
||||||
// Delete paths from the drive and/or shared folders (without moving them to the trash)
|
// Delete paths from the drive and/or shared folders (without moving them to the trash)
|
||||||
var deletePaths = function (paths, pathsList) {
|
var deletePaths = function (paths, pathsList) {
|
||||||
@ -1228,6 +1224,10 @@ define([
|
|||||||
paths.forEach(function (p) { pathsList.push(p.path); });
|
paths.forEach(function (p) { pathsList.push(p.path); });
|
||||||
}
|
}
|
||||||
var hasOwned = pathsList.some(function (p) {
|
var hasOwned = pathsList.some(function (p) {
|
||||||
|
// NOTE: Owned pads in shared folders won't be removed from the server
|
||||||
|
// so we don't have to check, we can use the default message
|
||||||
|
if (manager.isInSharedFolder(p)) { return false; }
|
||||||
|
|
||||||
var el = manager.find(p);
|
var el = manager.find(p);
|
||||||
var data = manager.isSharedFolder(el) ? manager.getSharedFolderData(el)
|
var data = manager.isSharedFolder(el) ? manager.getSharedFolderData(el)
|
||||||
: manager.getFileData(el);
|
: manager.getFileData(el);
|
||||||
@ -1310,7 +1310,7 @@ define([
|
|||||||
$('.cp-app-drive-element-droppable').removeClass('cp-app-drive-element-droppable');
|
$('.cp-app-drive-element-droppable').removeClass('cp-app-drive-element-droppable');
|
||||||
var data = ev.dataTransfer.getData("text");
|
var data = ev.dataTransfer.getData("text");
|
||||||
|
|
||||||
// Don't the the normal drop handler for file upload
|
// Don't use the normal drop handler for file upload
|
||||||
var fileDrop = ev.dataTransfer.files;
|
var fileDrop = ev.dataTransfer.files;
|
||||||
if (fileDrop.length) { return void onFileDrop(fileDrop, ev); }
|
if (fileDrop.length) { return void onFileDrop(fileDrop, ev); }
|
||||||
|
|
||||||
@ -1333,6 +1333,7 @@ define([
|
|||||||
return void deletePaths(null, movedPaths);
|
return void deletePaths(null, movedPaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var copy = false;
|
||||||
if (manager.isPathIn(newPath, [TRASH])) {
|
if (manager.isPathIn(newPath, [TRASH])) {
|
||||||
// Filter the selection to remove shared folders.
|
// Filter the selection to remove shared folders.
|
||||||
// Shared folders can't be moved to the trash!
|
// Shared folders can't be moved to the trash!
|
||||||
@ -1347,10 +1348,12 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
movedPaths = filteredPaths;
|
movedPaths = filteredPaths;
|
||||||
|
} else if (ev.ctrlKey || (ev.metaKey && APP.isMac)) {
|
||||||
|
copy = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (movedPaths && movedPaths.length) {
|
if (movedPaths && movedPaths.length) {
|
||||||
moveElements(movedPaths, newPath, null, refresh);
|
moveElements(movedPaths, newPath, copy, refresh);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user