Skip to content

Commit

Permalink
fix(files): Fix having to resolve conflicts twice when dropping files
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <chrng8@gmail.com>
  • Loading branch information
Pytal committed Sep 25, 2024
1 parent b33444c commit 1507877
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
24 changes: 13 additions & 11 deletions apps/files/src/actions/moveOrCopyAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,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
Expand Down
3 changes: 1 addition & 2 deletions apps/files/src/services/DropService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,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
Expand Down

0 comments on commit 1507877

Please sign in to comment.