Ferdinand Thiessen 1 week ago
committed by GitHub
parent
commit
b3ee6ecafd
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 15
      apps/files/src/services/DropService.ts
  2. 7
      apps/files/src/services/DropServiceUtils.ts

15
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<Upload[]> {
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 []

7
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<T extends ((Directory | File) | Node)>(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 []

Loading…
Cancel
Save