Skip to content

Commit 58fb003

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

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'
@@ -471,12 +472,17 @@ export default defineComponent({
471472
const items = Array.from(event.dataTransfer?.items || [])
472473

473474
if (selection.length === 0 && items.some((item) => item.kind === 'file')) {
475+
const files = items.filter((item) => item.kind === 'file')
476+
.map((item) => 'webkitGetAsEntry' in item ? item.webkitGetAsEntry() : item.getAsFile())
477+
.filter(Boolean) as (FileSystemEntry | File)[]
474478
const uploader = getUploader()
479+
const root = uploader.destination.path
480+
const relativePath = relative(root, this.source.path)
481+
logger.debug('Start uploading dropped files', { target: this.source.path, root, relativePath, files: files.map((file) => file.name) })
482+
475483
await uploader.batchUpload(
476-
this.source.path,
477-
items.filter((item) => item.kind === 'file')
478-
.map((item) => 'webkitGetAsEntry' in item ? item.webkitGetAsEntry() : item.getAsFile())
479-
.filter(Boolean) as (FileSystemEntry | File)[],
484+
relativePath,
485+
files,
480486
async (nodes, path) => {
481487
try {
482488
const { contents, folder } = await this.activeView!.getContents(path)
@@ -519,7 +525,7 @@ export default defineComponent({
519525
const isCopy = event.ctrlKey
520526
this.dragover = false
521527

522-
logger.debug('Dropped', { event, folder: this.source, selection, fileTree })
528+
logger.debug('Dropped', { event, folder: this.source, selection })
523529

524530
const nodes = selection.map((source) => this.filesStore.getNode(source)) as Node[]
525531
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
@@ -123,7 +123,7 @@ export async function onDropExternalFiles(root: RootDirectory, destination: Fold
123123
// then browse its tree and upload its contents.
124124
if (file instanceof Directory) {
125125
try {
126-
logger.debug('Processing directory', { relativePath })
126+
logger.debug('Processing directory', { relativePath, destination })
127127
await createDirectoryIfNotExists(relativePath, destination)
128128
await uploadDirectoryContents(file, relativePath)
129129
} catch (error) {

0 commit comments

Comments
 (0)