mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-13 16:40:01 +00:00
Fix NPE in ImageService when contentId of Image entity is null
This commit is contained in:
@@ -105,7 +105,7 @@ class GameService(
|
||||
imageService.downloadIfNew(it)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
log.error { "Error downloading images for game: ${e.message}" }
|
||||
log.error { "Error downloading images for game '${game.title}' (${game.id}): ${e.message}" }
|
||||
log.debug(e) {}
|
||||
null
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ class LibraryScanService(
|
||||
|
||||
game
|
||||
} catch (e: Exception) {
|
||||
log.error { "Error downloading images for game: ${e.message}" }
|
||||
log.error { "Error downloading images for game '${game.title}' (${game.id}): ${e.message}" }
|
||||
log.debug(e) {}
|
||||
null
|
||||
} finally {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package org.gameyfin.app.media
|
||||
|
||||
import org.apache.tika.Tika
|
||||
import org.apache.tika.io.TikaInputStream
|
||||
import org.gameyfin.app.games.entities.Image
|
||||
import org.gameyfin.app.games.entities.ImageType
|
||||
import org.gameyfin.app.games.repositories.ImageContentStore
|
||||
import org.apache.tika.Tika
|
||||
import org.apache.tika.io.TikaInputStream
|
||||
import org.gameyfin.app.games.repositories.ImageRepository
|
||||
import org.springframework.data.repository.findByIdOrNull
|
||||
import org.springframework.stereotype.Service
|
||||
@@ -22,8 +22,10 @@ class ImageService(
|
||||
fun downloadIfNew(image: Image) {
|
||||
if (image.originalUrl == null) throw IllegalArgumentException("Image must have an original URL")
|
||||
|
||||
imageRepository.findByOriginalUrl(image.originalUrl)?.let {
|
||||
imageContentStore.associate(image, it.contentId)
|
||||
val existingImage = imageRepository.findByOriginalUrl(image.originalUrl)
|
||||
|
||||
if (existingImage != null && existingImage.contentId != null) {
|
||||
imageContentStore.associate(image, existingImage.contentId)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user