diff options
author | Eduardo Morales <emoral435@gmail.com> | 2024-02-20 07:11:59 -0600 |
---|---|---|
committer | Eduardo Morales <emoral435@gmail.com> | 2024-02-23 20:08:58 -0600 |
commit | 67b0c7ce142595f71cfa6655d46bc57dd8e1ce90 (patch) | |
tree | 8c89209dc0346eb0081b160c36837f35c8e12e78 /apps/files | |
parent | 7e7b086c4e35aba962562482369d5cc7ad759e1f (diff) | |
download | nextcloud-server-67b0c7ce142595f71cfa6655d46bc57dd8e1ce90.tar.gz nextcloud-server-67b0c7ce142595f71cfa6655d46bc57dd8e1ce90.zip |
fix: conflict picker moves files correctly to its directory
Signed-off-by: Eduardo Morales <emoral435@gmail.com>
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/src/actions/moveOrCopyAction.ts | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/apps/files/src/actions/moveOrCopyAction.ts b/apps/files/src/actions/moveOrCopyAction.ts index e0789f5da60..d85f18f00a3 100644 --- a/apps/files/src/actions/moveOrCopyAction.ts +++ b/apps/files/src/actions/moveOrCopyAction.ts @@ -32,7 +32,7 @@ import { emit } from '@nextcloud/event-bus' import { FilePickerClosed, getFilePickerBuilder, showError } from '@nextcloud/dialogs' import { Permission, FileAction, FileType, NodeStatus, davGetClient, davRootPath, davResultToNode, davGetDefaultPropfind } from '@nextcloud/files' import { translate as t } from '@nextcloud/l10n' -import { openConflictPicker, hasConflict } from '@nextcloud/upload' +import { getUploader, openConflictPicker, hasConflict } from '@nextcloud/upload' import Vue from 'vue' import CopyIconSvg from '@mdi/svg/svg/folder-multiple.svg?raw' @@ -136,13 +136,34 @@ export const handleCopyMoveNodeTo = async (node: Node, destination: Folder, meth } } else { // show conflict file popup if we do not allow overwriting - if (!overwrite) { - const contents = await getContents(destinationPath) - if (hasConflict([node], contents.contents)) { - await openConflictPicker + logger.debug("NO CONFLICTS SHOULD BE FOUND11") + const otherNodes = await getContents(destination.path) + logger.debug("NO CONFLICTS SHOULD BE FOUND2") + let files: (Node|File)[] = [node] + if (hasConflict([node], otherNodes.contents)) { + const conflicts = otherNodes.contents.filter((otherNode: Node) => { + return otherNode.basename === node.basename + }).filter(Boolean) as Node[] + + const uploads = otherNodes.contents.filter((otherNode: Node) => { + return !conflicts.includes(otherNode) + }) + + try { + // Let the user choose what to do with the conflicting files + const { selected, renamed } = await openConflictPicker(destination.path, conflicts, otherNodes.contents) + files = [...uploads, ...selected, ...renamed] + } catch (error) { + // User cancelled + showError(t('files','Upload cancelled')) + return } + } + + logger.debug("NO CONFLICTS SHOULD BE FOUND") await client.moveFile(currentPath, join(destinationPath, node.basename)) + logger.debug("FINALLY DELETE THE NODE") // Delete the node as it will be fetched again // when navigating to the destination folder emit('files:node:deleted', node) |