diff --git a/apps/files/src/components/FileEntryMixin.ts b/apps/files/src/components/FileEntryMixin.ts index 0831c50afd6f8..f13a1a224b6a2 100644 --- a/apps/files/src/components/FileEntryMixin.ts +++ b/apps/files/src/components/FileEntryMixin.ts @@ -473,19 +473,19 @@ export default defineComponent({ if (selection.length === 0 && items.some((item) => item.kind === 'file')) { const files = items.filter((item) => item.kind === 'file') - .map((item) => 'webkitGetAsEntry' in item ? item.webkitGetAsEntry() : item.getAsFile()) - .filter(Boolean) as (FileSystemEntry | File)[] + .map((item) => item.getAsFile()).filter((file): file is File => !!file) + .filter(Boolean) as (FileSystemEntry | File)[], const uploader = getUploader() - const root = uploader.destination.path - const relativePath = relative(root, this.source.path) - logger.debug('Start uploading dropped files', { target: this.source.path, root, relativePath, files: files.map((file) => file.name) }) - + let targetPath = this.source.path.replace(this.currentDir || '', '') + if (!targetPath.startsWith('/')) { + targetPath = '/' + targetPath + } await uploader.batchUpload( - relativePath, + targetPath, files, async (nodes, path) => { try { - const { contents, folder } = await this.activeView!.getContents(path) + const { contents, folder } = await this.currentView!.getContents(path) const conflicts = getConflicts(nodes, contents) if (conflicts.length === 0) { return nodes @@ -517,17 +517,17 @@ export default defineComponent({ } // We might not have the target directory fetched yet - const cachedContents = this.filesStore.getNodesByPath(this.activeView.id, this.source.path) + const cachedContents = this.filesStore.getNodesByPath(this.currentView.id, this.source.path) const contents = cachedContents.length === 0 - ? (await this.activeView!.getContents(this.source.path)).contents + ? (await this.currentView!.getContents(this.source.path)).contents : cachedContents const isCopy = event.ctrlKey this.dragover = false - logger.debug('Dropped', { event, folder: this.source, selection }) + logger.debug('Dropped', { event, folder: this.source, selection, contents }) - const nodes = selection.map((source) => this.filesStore.getNode(source)) as Node[] + const nodes = selection.map((source) => this.filesStore.getNode(source)).filter((node): node is Node => !!node) await onDropInternalFiles(nodes, this.source, contents, isCopy) // Reset selection after we dropped the files