Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 41 additions & 8 deletions apps/files/src/components/FileEntryMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import Vue, { computed, defineComponent } from 'vue'

import { action as sidebarAction } from '../actions/sidebarAction.ts'
import { dataTransferToFileTree, onDropExternalFiles, onDropInternalFiles } from '../services/DropService.ts'

Check failure on line 19 in apps/files/src/components/FileEntryMixin.ts

View workflow job for this annotation

GitHub Actions / NPM lint

'onDropExternalFiles' is defined but never used
import { getDragAndDropPreview } from '../utils/dragUtils.ts'
import { hashCode } from '../utils/hashUtils.ts'
import { isDownloadable } from '../utils/permissions.ts'
Expand Down Expand Up @@ -465,7 +465,7 @@

// We need to process the dataTransfer ASAP before the
// browser clears it. This is why we cache the items too.
const fileTree = await dataTransferToFileTree(items)

Check failure on line 468 in apps/files/src/components/FileEntryMixin.ts

View workflow job for this annotation

GitHub Actions / NPM lint

'fileTree' is assigned a value but never used

// We might not have the target directory fetched yet
const contents = await this.currentView?.getContents(this.source.path)
Expand All @@ -481,14 +481,47 @@
return
}

const isCopy = event.ctrlKey
this.dragover = false

logger.debug('Dropped', { event, folder, selection, fileTree })

// Check whether we're uploading files
if (selection.length === 0 && fileTree.contents.length > 0) {
await onDropExternalFiles(fileTree, folder, contents.contents)
// Caching the selection
const selection = this.draggingFiles
const items = Array.from(event.dataTransfer?.items || [])

if (selection.length === 0 && items.some((item) => item.kind === 'file')) {
const uploader = getUploader()
await uploader.batchUpload(
this.source.path,
items.filter((item) => item.kind === 'file')
.map((item) => 'webkitGetAsEntry' in item ? item.webkitGetAsEntry() : item.getAsFile())
.filter(Boolean) as (FileSystemEntry | File)[],
async (nodes, path) => {
try {
const { contents, folder } = await this.activeView!.getContents(path)
const conflicts = getConflicts(nodes, contents)
if (conflicts.length === 0) {
return nodes
}

const result = await openConflictPicker(
folder.displayname,
conflicts,
(contents as Node[]).filter((node) => conflicts.some((conflict) => conflict.name === node.basename)),
{
recursive: true,
},
)
if (result === null) {
return false
}
return [
...nodes.filter((node) => !conflicts.some((conflict) => conflict.name === node.name)),
...result.selected,
...result.renamed,
]
} catch {
return nodes
}
},
)
this.dragover = false
return
}

Expand Down
Loading