Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(files): Fix having to resolve conflicts twice when dropping files #48331

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions apps/files/src/actions/moveOrCopyAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,21 @@
}
} 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 Expand Up @@ -170,7 +172,7 @@
* @param action The action to open the file picker for
* @param dir The directory to start the file picker in
* @param nodes The nodes to move/copy
* @return The picked destination or false if cancelled by user

Check warning on line 175 in apps/files/src/actions/moveOrCopyAction.ts

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc @return type
*/
async function openFilePickerForAction(
action: MoveCopyAction,
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 @@ -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
Expand Down
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.

Loading