]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(files): Fix having to resolve conflicts twice when dropping files
authorChristopher Ng <chrng8@gmail.com>
Tue, 24 Sep 2024 23:01:05 +0000 (16:01 -0700)
committerChristopher Ng <chrng8@gmail.com>
Tue, 24 Sep 2024 23:01:05 +0000 (16:01 -0700)
Signed-off-by: Christopher Ng <chrng8@gmail.com>
apps/files/src/actions/moveOrCopyAction.ts
apps/files/src/services/DropService.ts

index 13840540a38e0a61bac52a0bad764eb91158690d..78424c748cd4fa3456e49dc10b995b8872bf9058 100644 (file)
@@ -123,19 +123,21 @@ export const handleCopyMoveNodeTo = async (node: Node, destination: Folder, meth
                                }
                        } else {
                                // show conflict file popup if we do not allow overwriting
-                               const otherNodes = await getContents(destination.path)
-                               if (hasConflict([node], otherNodes.contents)) {
-                                       try {
-                                               // Let the user choose what to do with the conflicting files
-                                               const { selected, renamed } = await openConflictPicker(destination.path, [node], otherNodes.contents)
-                                               // two empty arrays: either only old files or conflict skipped -> no action required
-                                               if (!selected.length && !renamed.length) {
+                               if (!overwrite) {
+                                       const otherNodes = await getContents(destination.path)
+                                       if (hasConflict([node], otherNodes.contents)) {
+                                               try {
+                                                       // Let the user choose what to do with the conflicting files
+                                                       const { selected, renamed } = await openConflictPicker(destination.path, [node], otherNodes.contents)
+                                                       // two empty arrays: either only old files or conflict skipped -> no action required
+                                                       if (!selected.length && !renamed.length) {
+                                                               return
+                                                       }
+                                               } catch (error) {
+                                                       // User cancelled
+                                                       showError(t('files', 'Move cancelled'))
                                                        return
                                                }
-                                       } catch (error) {
-                                               // User cancelled
-                                               showError(t('files', 'Move cancelled'))
-                                               return
                                        }
                                }
                                // getting here means either no conflict, file was renamed to keep both files
index 63e7c213f4f29924d978451573b7caa673fd9543..1013baeda6c060c74fd7166ec96a7d4eb5a8e5fc 100644 (file)
@@ -178,8 +178,7 @@ export const onDropInternalFiles = async (nodes: Node[], destination: Folder, co
 
        for (const node of nodes) {
                Vue.set(node, 'status', NodeStatus.LOADING)
-               // TODO: resolve potential conflicts prior and force overwrite
-               queue.push(handleCopyMoveNodeTo(node, destination, isCopy ? MoveCopyAction.COPY : MoveCopyAction.MOVE))
+               queue.push(handleCopyMoveNodeTo(node, destination, isCopy ? MoveCopyAction.COPY : MoveCopyAction.MOVE, true))
        }
 
        // Wait for all promises to settle