Skip to content

Commit a5d2f9a

Browse files
committed
fix(files): properly handle dropped files on subfolders
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent f94077c commit a5d2f9a

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

apps/files/src/components/FileEntryMixin.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { isPublicShare } from '@nextcloud/sharing/public'
1414
import { generateUrl } from '@nextcloud/router'
1515
import { getConflicts, getUploader } from '@nextcloud/upload'
1616
import { vOnClickOutside } from '@vueuse/components'
17+
import { relative } from 'path'
1718
import Vue, { computed, defineComponent } from 'vue'
1819

1920
import { action as sidebarAction } from '../actions/sidebarAction.ts'
@@ -433,12 +434,17 @@ export default defineComponent({
433434
const items = Array.from(event.dataTransfer?.items || [])
434435

435436
if (selection.length === 0 && items.some((item) => item.kind === 'file')) {
437+
const files = items.filter((item) => item.kind === 'file')
438+
.map((item) => 'webkitGetAsEntry' in item ? item.webkitGetAsEntry() : item.getAsFile())
439+
.filter(Boolean) as (FileSystemEntry | File)[]
436440
const uploader = getUploader()
441+
const root = uploader.destination.path
442+
const relativePath = relative(root, this.source.path)
443+
logger.debug('Start uploading dropped files', { target: this.source.path, root, relativePath, files: files.map((file) => file.name) })
444+
437445
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)[],
446+
relativePath,
447+
files,
442448
async (nodes, path) => {
443449
try {
444450
const { contents, folder } = await this.activeView!.getContents(path)
@@ -481,7 +487,7 @@ export default defineComponent({
481487
const isCopy = event.ctrlKey
482488
this.dragover = false
483489

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

486492
const nodes = selection.map((source) => this.filesStore.getNode(source)) as Node[]
487493
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)