Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
ensure thumbnails only ever assign themselves as their thumbnail (#10957
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dinomut1 authored Aug 15, 2024
1 parent 61081ca commit 2b3a57d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
12 changes: 9 additions & 3 deletions packages/server-core/src/projects/project/project-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2b3a57d

Please sign in to comment.