mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-17 08:15:44 +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)
|
imageService.downloadIfNew(it)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} 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) {}
|
log.debug(e) {}
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -376,7 +376,7 @@ class LibraryScanService(
|
|||||||
|
|
||||||
game
|
game
|
||||||
} catch (e: Exception) {
|
} 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) {}
|
log.debug(e) {}
|
||||||
null
|
null
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package org.gameyfin.app.media
|
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.Image
|
||||||
import org.gameyfin.app.games.entities.ImageType
|
import org.gameyfin.app.games.entities.ImageType
|
||||||
import org.gameyfin.app.games.repositories.ImageContentStore
|
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.gameyfin.app.games.repositories.ImageRepository
|
||||||
import org.springframework.data.repository.findByIdOrNull
|
import org.springframework.data.repository.findByIdOrNull
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
@@ -22,8 +22,10 @@ class ImageService(
|
|||||||
fun downloadIfNew(image: Image) {
|
fun downloadIfNew(image: Image) {
|
||||||
if (image.originalUrl == null) throw IllegalArgumentException("Image must have an original URL")
|
if (image.originalUrl == null) throw IllegalArgumentException("Image must have an original URL")
|
||||||
|
|
||||||
imageRepository.findByOriginalUrl(image.originalUrl)?.let {
|
val existingImage = imageRepository.findByOriginalUrl(image.originalUrl)
|
||||||
imageContentStore.associate(image, it.contentId)
|
|
||||||
|
if (existingImage != null && existingImage.contentId != null) {
|
||||||
|
imageContentStore.associate(image, existingImage.contentId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user