Merge pull request #55575 from nextcloud/fix/drag-drop-error

fix(files): make sure drag-and-drop and the upload menu behaves the same
chore/psalm-level-3
Ferdinand Thiessen 2025-10-28 18:16:05 +07:00 committed by GitHub
commit 4b5494c5ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 13 deletions

@ -90,10 +90,11 @@ export async function dataTransferToFileTree(items: DataTransferItem[]): Promise
} }
/** /**
* Handle dropping external files
* *
* @param root * @param root - The root directory which should be uploaded
* @param destination * @param destination - The destination folder
* @param contents * @param contents - The contents of the destination folder
*/ */
export async function onDropExternalFiles(root: RootDirectory, destination: Folder, contents: Node[]): Promise<Upload[]> { export async function onDropExternalFiles(root: RootDirectory, destination: Folder, contents: Node[]): Promise<Upload[]> {
const uploader = getUploader() const uploader = getUploader()
@ -101,9 +102,11 @@ export async function onDropExternalFiles(root: RootDirectory, destination: Fold
// Check for conflicts on root elements // Check for conflicts on root elements
if (await hasConflict(root.contents, contents)) { if (await hasConflict(root.contents, contents)) {
root.contents = await resolveConflict(root.contents, destination, contents) root.contents = await resolveConflict(root.contents, destination, contents)
} if (root.contents.length === 0) {
// user cancelled the upload
if (root.contents.length === 0) { return []
}
} else if (root.contents.length === 0) {
logger.info('No files to upload', { root }) logger.info('No files to upload', { root })
showInfo(t('files', 'No files to upload')) showInfo(t('files', 'No files to upload'))
return [] return []

@ -5,7 +5,7 @@ import type { Folder, Node } from '@nextcloud/files'
*/ */
import type { FileStat, ResponseDataDetailed } from 'webdav' 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 { emit } from '@nextcloud/event-bus'
import { davGetClient, davGetDefaultPropfind, davResultToNode } from '@nextcloud/files' import { davGetClient, davGetDefaultPropfind, davResultToNode } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n' import { translate as t } from '@nextcloud/l10n'
@ -179,10 +179,9 @@ export async function resolveConflict<T extends ((Directory | File) | Node)>(fil
// Update the list of files to upload // Update the list of files to upload
return [...uploads, ...selected, ...renamed] as (typeof files) return [...uploads, ...selected, ...renamed] as (typeof files)
} catch (error) { } catch (error) {
logger.error(error as Error)
// User cancelled // User cancelled
showError(t('files', 'Upload cancelled')) logger.warn('User cancelled the upload', { error })
logger.error('User cancelled the upload') showWarning(t('files', 'Upload cancelled'))
} }
return [] return []

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long