From d6925b6b79ecc5e1b1bd0785f5912942101271e2 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Mon, 6 Oct 2025 15:36:15 +0200 Subject: [PATCH] fix(files): make sure drag-and-drop and the upload menu behaves the same Signed-off-by: Ferdinand Thiessen --- apps/files/src/services/DropService.ts | 15 +++++++++------ apps/files/src/services/DropServiceUtils.ts | 7 +++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/apps/files/src/services/DropService.ts b/apps/files/src/services/DropService.ts index da082aac30a..c28423ef5b3 100644 --- a/apps/files/src/services/DropService.ts +++ b/apps/files/src/services/DropService.ts @@ -90,10 +90,11 @@ export async function dataTransferToFileTree(items: DataTransferItem[]): Promise } /** + * Handle dropping external files * - * @param root - * @param destination - * @param contents + * @param root - The root directory which should be uploaded + * @param destination - The destination folder + * @param contents - The contents of the destination folder */ export async function onDropExternalFiles(root: RootDirectory, destination: Folder, contents: Node[]): Promise { const uploader = getUploader() @@ -101,9 +102,11 @@ export async function onDropExternalFiles(root: RootDirectory, destination: Fold // Check for conflicts on root elements if (await hasConflict(root.contents, contents)) { root.contents = await resolveConflict(root.contents, destination, contents) - } - - if (root.contents.length === 0) { + if (root.contents.length === 0) { + // user cancelled the upload + return [] + } + } else if (root.contents.length === 0) { logger.info('No files to upload', { root }) showInfo(t('files', 'No files to upload')) return [] diff --git a/apps/files/src/services/DropServiceUtils.ts b/apps/files/src/services/DropServiceUtils.ts index 782c9049118..e10166ecf02 100644 --- a/apps/files/src/services/DropServiceUtils.ts +++ b/apps/files/src/services/DropServiceUtils.ts @@ -5,7 +5,7 @@ import type { Folder, Node } from '@nextcloud/files' */ import type { FileStat, ResponseDataDetailed } from 'webdav' -import { showError, showInfo } from '@nextcloud/dialogs' +import { showInfo, showWarning } from '@nextcloud/dialogs' import { emit } from '@nextcloud/event-bus' import { davGetClient, davGetDefaultPropfind, davResultToNode } from '@nextcloud/files' import { translate as t } from '@nextcloud/l10n' @@ -179,10 +179,9 @@ export async function resolveConflict(fil // Update the list of files to upload return [...uploads, ...selected, ...renamed] as (typeof files) } catch (error) { - logger.error(error as Error) // User cancelled - showError(t('files', 'Upload cancelled')) - logger.error('User cancelled the upload') + logger.warn('User cancelled the upload', { error }) + showWarning(t('files', 'Upload cancelled')) } return []