Skip to content

Commit 288ed89

Browse files
solracsfsusnux
authored andcommitted
fix(files): use type field instead of instanceof for Folder
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
1 parent e780720 commit 288ed89

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

apps/files/src/components/FileEntryMixin.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,10 @@ export default defineComponent({
480480
// canDrop already gates this branch on FileType.Folder, but the
481481
// type system can't see that — narrow defensively so a future
482482
// loosening of canDrop can't silently lie via the cast below.
483-
if (!(this.source instanceof Folder)) {
483+
// Use the `type` field rather than `instanceof Folder`: apps
484+
// bundle their own copy of @nextcloud/files, so a Folder from
485+
// an app would not be `instanceof` the server's Folder class.
486+
if (this.source.type !== FileType.Folder) {
484487
logger.error('onDrop: external drop target is not a Folder', { source: this.source })
485488
this.dragover = false
486489
return
@@ -493,7 +496,7 @@ export default defineComponent({
493496
: cachedContents
494497

495498
logger.debug('Start uploading dropped files', { target: this.source.path, fileTree })
496-
await onDropExternalFiles(fileTree, this.source, contents)
499+
await onDropExternalFiles(fileTree, this.source as Folder, contents)
497500
this.dragover = false
498501
return
499502
}

0 commit comments

Comments
 (0)