Skip to content

Commit 4b26578

Browse files
committed
fix(files): Fix having to resolve conflicts twice when dropping files
Signed-off-by: Christopher Ng <chrng8@gmail.com>
1 parent 3225dc5 commit 4b26578

2 files changed

Lines changed: 14 additions & 13 deletions

File tree

apps/files/src/actions/moveOrCopyAction.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -142,19 +142,21 @@ export const handleCopyMoveNodeTo = async (node: Node, destination: Folder, meth
142142
}
143143
} else {
144144
// show conflict file popup if we do not allow overwriting
145-
const otherNodes = await getContents(destination.path)
146-
if (hasConflict([node], otherNodes.contents)) {
147-
try {
148-
// Let the user choose what to do with the conflicting files
149-
const { selected, renamed } = await openConflictPicker(destination.path, [node], otherNodes.contents)
150-
// two empty arrays: either only old files or conflict skipped -> no action required
151-
if (!selected.length && !renamed.length) {
145+
if (!overwrite) {
146+
const otherNodes = await getContents(destination.path)
147+
if (hasConflict([node], otherNodes.contents)) {
148+
try {
149+
// Let the user choose what to do with the conflicting files
150+
const { selected, renamed } = await openConflictPicker(destination.path, [node], otherNodes.contents)
151+
// two empty arrays: either only old files or conflict skipped -> no action required
152+
if (!selected.length && !renamed.length) {
153+
return
154+
}
155+
} catch (error) {
156+
// User cancelled
157+
showError(t('files', 'Move cancelled'))
152158
return
153159
}
154-
} catch (error) {
155-
// User cancelled
156-
showError(t('files', 'Move cancelled'))
157-
return
158160
}
159161
}
160162
// getting here means either no conflict, file was renamed to keep both files

apps/files/src/services/DropService.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,7 @@ export const onDropInternalFiles = async (nodes: Node[], destination: Folder, co
196196

197197
for (const node of nodes) {
198198
Vue.set(node, 'status', NodeStatus.LOADING)
199-
// TODO: resolve potential conflicts prior and force overwrite
200-
queue.push(handleCopyMoveNodeTo(node, destination, isCopy ? MoveCopyAction.COPY : MoveCopyAction.MOVE))
199+
queue.push(handleCopyMoveNodeTo(node, destination, isCopy ? MoveCopyAction.COPY : MoveCopyAction.MOVE, true))
201200
}
202201

203202
// Wait for all promises to settle

0 commit comments

Comments
 (0)