aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorEduardo Morales <emoral435@gmail.com>2024-02-20 11:19:48 -0600
committerEduardo Morales <emoral435@gmail.com>2024-02-23 20:08:58 -0600
commitf168187dc910741faeba3c1037f099bb7176d7e8 (patch)
tree3b97c89c5a058cf315dd2a7021ed94a4a37242b2 /apps/files
parent67b0c7ce142595f71cfa6655d46bc57dd8e1ce90 (diff)
downloadnextcloud-server-f168187dc910741faeba3c1037f099bb7176d7e8.tar.gz
nextcloud-server-f168187dc910741faeba3c1037f099bb7176d7e8.zip
feat: files update correctly on destination/current folder
Signed-off-by: Eduardo Morales <emoral435@gmail.com>
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/src/actions/moveOrCopyAction.ts31
1 files changed, 12 insertions, 19 deletions
diff --git a/apps/files/src/actions/moveOrCopyAction.ts b/apps/files/src/actions/moveOrCopyAction.ts
index d85f18f00a3..0249c27208c 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 { getUploader, openConflictPicker, hasConflict } from '@nextcloud/upload'
+import { openConflictPicker, hasConflict } from '@nextcloud/upload'
import Vue from 'vue'
import CopyIconSvg from '@mdi/svg/svg/folder-multiple.svg?raw'
@@ -136,34 +136,27 @@ export const handleCopyMoveNodeTo = async (node: Node, destination: Folder, meth
}
} else {
// show conflict file popup if we do not allow overwriting
- 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]
+ const { selected, renamed } = await openConflictPicker(destination.path, [node], otherNodes.contents)
+ // if the user selected to keep the old file, and did not select the new file
+ // that means they opted to delete the current node
+ if (!selected.length && !renamed.length) {
+ await client.deleteFile(currentPath)
+ emit('files:node:deleted', node)
+ return
+ }
} catch (error) {
// User cancelled
- showError(t('files','Upload cancelled'))
+ showError(t('files','Move cancelled'))
return
}
-
}
-
- logger.debug("NO CONFLICTS SHOULD BE FOUND")
+ // getting here means either no conflict, file was renamed to keep both files
+ // in a conflict, or the selected file was chosen to be kept during the conflict
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)