Skip to content

Commit 23a96c2

Browse files
solracsfbackportbot[bot]
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 e219863 commit 23a96c2

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
@@ -497,7 +497,10 @@ export default defineComponent({
497497
// canDrop already gates this branch on FileType.Folder, but the
498498
// type system can't see that — narrow defensively so a future
499499
// loosening of canDrop can't silently lie via the cast below.
500-
if (!(this.source instanceof Folder)) {
500+
// Use the `type` field rather than `instanceof Folder`: apps
501+
// bundle their own copy of @nextcloud/files, so a Folder from
502+
// an app would not be `instanceof` the server's Folder class.
503+
if (this.source.type !== FileType.Folder) {
501504
logger.error('onDrop: external drop target is not a Folder', { source: this.source })
502505
this.dragover = false
503506
return
@@ -510,7 +513,7 @@ export default defineComponent({
510513
: cachedContents
511514

512515
logger.debug('Start uploading dropped files', { target: this.source.path, fileTree })
513-
await onDropExternalFiles(fileTree, this.source, contents)
516+
await onDropExternalFiles(fileTree, this.source as Folder, contents)
514517
this.dragover = false
515518
return
516519
}

0 commit comments

Comments
 (0)