Skip to content

Commit

Permalink
IR-6253: prevent default scene thumbnail to be deleted when deleting …
Browse files Browse the repository at this point in the history
…scene (#923)

fix: prevent default scene thumbnail to be deleted when deleting scene
  • Loading branch information
jose-galvan authored Jan 11, 2025
1 parent d876e0f commit a81521b
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,14 @@ export class FileBrowserService
return staticResource
}

/**
* Used to verify when a scene is deleted and has the default thumbnail.
* This prevents the default thumbnail from being deleted.
*/
private isDefaultThumbnail(thumbnail: StaticResourceType): boolean {
return thumbnail.name === 'default.thumbnail.jpg' && thumbnail.project === 'ir-engine/default-project'
}

/**
* Remove a directory
*/
Expand Down Expand Up @@ -551,8 +559,7 @@ export class FileBrowserService
query: { key: { $like: `%${resource.thumbnailKey}%` }, type: 'thumbnail' },
paginate: false
})) as any as StaticResourceType[]

if (thumbnail.length > 0) {
if (thumbnail.length > 0 && !this.isDefaultThumbnail(thumbnail[0])) {
await storageProvider.deleteResources([thumbnail[0].key])
await this.app.service(staticResourcePath).remove(thumbnail[0].id)
}
Expand Down

0 comments on commit a81521b

Please sign in to comment.