Skip to content

Commit

Permalink
Merge pull request #43811 from nextcloud/backport/43667/stable28
Browse files Browse the repository at this point in the history
[stable28] fix: merge conflict dialog added when overwriting files on move-file action
  • Loading branch information
emoral435 committed Mar 9, 2024
2 parents f259d7a + ed0ad08 commit da2a6c0
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 18 deletions.
23 changes: 23 additions & 0 deletions apps/files/src/actions/moveOrCopyAction.ts
Expand Up @@ -32,12 +32,14 @@ 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 Vue from 'vue'

import CopyIconSvg from '@mdi/svg/svg/folder-multiple.svg?raw'
import FolderMoveSvg from '@mdi/svg/svg/folder-move.svg?raw'

import { MoveCopyAction, canCopy, canMove, getQueue } from './moveOrCopyActionUtils'
import { getContents } from '../services/Files'
import logger from '../logger'
import { getUniqueName } from '../utils/fileUtils'

Expand Down Expand Up @@ -133,6 +135,27 @@ export const handleCopyMoveNodeTo = async (node: Node, destination: Folder, meth
emit('files:node:created', davResultToNode(data))
}
} 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)
// 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','Move cancelled'))
return
}
}
// 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))
// Delete the node as it will be fetched again
// when navigating to the destination folder
Expand Down
4 changes: 2 additions & 2 deletions dist/comments-comments-app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/comments-comments-app.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/comments-comments-tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/comments-comments-tab.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-common.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-init.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/systemtags-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/systemtags-init.js.map

Large diffs are not rendered by default.

0 comments on commit da2a6c0

Please sign in to comment.