From 2b3a57d77906fe69ecd47359104fb4c9e3750c90 Mon Sep 17 00:00:00 2001 From: David Gordon <94419856+dinomut1@users.noreply.github.com> Date: Thu, 15 Aug 2024 10:26:01 -0700 Subject: [PATCH] ensure thumbnails only ever assign themselves as their thumbnail (#10957) --- .../src/common/services/FileThumbnailJobState.tsx | 6 ++++++ .../src/projects/project/project-helper.ts | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/client-core/src/common/services/FileThumbnailJobState.tsx b/packages/client-core/src/common/services/FileThumbnailJobState.tsx index 96f65cb962..148bac50a5 100644 --- a/packages/client-core/src/common/services/FileThumbnailJobState.tsx +++ b/packages/client-core/src/common/services/FileThumbnailJobState.tsx @@ -158,6 +158,12 @@ export const FileThumbnailJobState = defineState({ if (seenResources.has(resource.key)) continue seenResources.add(resource.key) + if (resource.type === 'thumbnail') { + //set thumbnail's thumbnail as itself + Engine.instance.api.service(staticResourcePath).patch(resource.id, { thumbnailKey: resource.key }) + continue + } + if (resource.thumbnailKey != null || !extensionCanHaveThumbnail(resource.key.split('.').pop() ?? '')) continue getMutableState(FileThumbnailJobState).merge([ diff --git a/packages/server-core/src/projects/project/project-helper.ts b/packages/server-core/src/projects/project/project-helper.ts index fe7121309d..a40a792edd 100644 --- a/packages/server-core/src/projects/project/project-helper.ts +++ b/packages/server-core/src/projects/project/project-helper.ts @@ -1784,9 +1784,15 @@ export const uploadLocalProjectToProvider = async ( const stats = await getStats(fileResult, contentType) const resourceInfo = resourcesJson?.[filePathRelative] const type = isScene ? 'scene' : getResourceType(filePathRelative, resourceInfo!) - const thumbnailKey = - resourceInfo?.thumbnailKey ?? (isScene ? key.split('.').slice(0, -1).join('.') + '.thumbnail.jpg' : undefined) - + let thumbnailKey = resourceInfo?.thumbnailKey + if (!thumbnailKey) { + if (isScene) { + thumbnailKey = key.split('.').slice(0, -1).join('.') + '.thumbnail.jpg' + } else if (type === 'thumbnail') { + //since thumbnails are not in resource json, we need to redefine their thumbnail keys here + thumbnailKey = key + } + } if (existingKeySet.has(key)) { const id = existingKeySet.get(key)! existingKeySet.delete(key)