Skip to content

Commit 8233a9a

Browse files
susnuxbackportbot[bot]
authored andcommitted
fix(files): properly handle dropped files on subfolders
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent f94077c commit 8233a9a

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

apps/files/src/components/FileEntryMixin.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,17 @@ export default defineComponent({
433433
const items = Array.from(event.dataTransfer?.items || [])
434434

435435
if (selection.length === 0 && items.some((item) => item.kind === 'file')) {
436+
const files = items.filter((item) => item.kind === 'file')
437+
.map((item) => 'webkitGetAsEntry' in item ? item.webkitGetAsEntry() : item.getAsFile())
438+
.filter(Boolean) as (FileSystemEntry | File)[]
436439
const uploader = getUploader()
440+
const root = uploader.destination.path
441+
const relativePath = relative(root, this.source.path)
442+
logger.debug('Start uploading dropped files', { target: this.source.path, root, relativePath, files: files.map((file) => file.name) })
443+
437444
await uploader.batchUpload(
438-
this.source.path,
439-
items.filter((item) => item.kind === 'file')
440-
.map((item) => 'webkitGetAsEntry' in item ? item.webkitGetAsEntry() : item.getAsFile())
441-
.filter(Boolean) as (FileSystemEntry | File)[],
445+
relativePath,
446+
files,
442447
async (nodes, path) => {
443448
try {
444449
const { contents, folder } = await this.activeView!.getContents(path)
@@ -481,7 +486,7 @@ export default defineComponent({
481486
const isCopy = event.ctrlKey
482487
this.dragover = false
483488

484-
logger.debug('Dropped', { event, folder: this.source, selection, fileTree })
489+
logger.debug('Dropped', { event, folder: this.source, selection })
485490

486491
const nodes = selection.map((source) => this.filesStore.getNode(source)) as Node[]
487492
await onDropInternalFiles(nodes, this.source, contents, isCopy)

apps/files/src/services/DropService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export async function onDropExternalFiles(root: RootDirectory, destination: IFol
126126
// then browse its tree and upload its contents.
127127
if (file instanceof Directory) {
128128
try {
129-
logger.debug('Processing directory', { relativePath })
129+
logger.debug('Processing directory', { relativePath, destination })
130130
await createDirectoryIfNotExists(relativePath, destination)
131131
await uploadDirectoryContents(file, relativePath)
132132
} catch (error) {

0 commit comments

Comments
 (0)