Skip to content

Commit 572d5f6

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

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

apps/files/src/components/FileEntryMixin.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { generateUrl } from '@nextcloud/router'
1414
import { isPublicShare } from '@nextcloud/sharing/public'
1515
import { getConflicts, getUploader } from '@nextcloud/upload'
1616
import { vOnClickOutside } from '@vueuse/components'
17-
import { extname } from 'path'
17+
import { extname, relative } from 'path'
1818
import Vue, { computed, defineComponent } from 'vue'
1919
import { action as sidebarAction } from '../actions/sidebarAction.ts'
2020
import logger from '../logger.ts'
@@ -488,12 +488,17 @@ export default defineComponent({
488488
const items = Array.from(event.dataTransfer?.items || [])
489489

490490
if (selection.length === 0 && items.some((item) => item.kind === 'file')) {
491+
const files = items.filter((item) => item.kind === 'file')
492+
.map((item) => 'webkitGetAsEntry' in item ? item.webkitGetAsEntry() : item.getAsFile())
493+
.filter(Boolean) as (FileSystemEntry | File)[]
491494
const uploader = getUploader()
495+
const root = uploader.destination.path
496+
const relativePath = relative(root, this.source.path)
497+
logger.debug('Start uploading dropped files', { target: this.source.path, root, relativePath, files: files.map((file) => file.name) })
498+
492499
await uploader.batchUpload(
493-
this.source.path,
494-
items.filter((item) => item.kind === 'file')
495-
.map((item) => 'webkitGetAsEntry' in item ? item.webkitGetAsEntry() : item.getAsFile())
496-
.filter(Boolean) as (FileSystemEntry | File)[],
500+
relativePath,
501+
files,
497502
async (nodes, path) => {
498503
try {
499504
const { contents, folder } = await this.activeView!.getContents(path)
@@ -536,7 +541,7 @@ export default defineComponent({
536541
const isCopy = event.ctrlKey
537542
this.dragover = false
538543

539-
logger.debug('Dropped', { event, folder: this.source, selection, fileTree })
544+
logger.debug('Dropped', { event, folder: this.source, selection })
540545

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