mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-13 16:40:01 +00:00
Added additional check if a game with a slug exists, so the user does not overwrite a mapping accidentally
This commit is contained in:
@@ -6,4 +6,5 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
public interface DetectedGameRepository extends JpaRepository<DetectedGame, String> {
|
||||
|
||||
boolean existsByPath(String path);
|
||||
boolean existsBySlug(String slug);
|
||||
}
|
||||
|
||||
@@ -36,9 +36,13 @@ public class GameService {
|
||||
}
|
||||
|
||||
public DetectedGame mapUnmappedFile(Long unmappedGameId, String igdbSlug) {
|
||||
|
||||
UnmappableFile unmappableFile = unmappableFileRepository.findById(unmappedGameId)
|
||||
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "Unmapped file with id '%d' does not exist.".formatted(unmappedGameId)));
|
||||
|
||||
if(detectedGameRepository.existsBySlug(igdbSlug))
|
||||
throw new ResponseStatusException(HttpStatus.CONFLICT, "Game with slug '%s' already exists in database.".formatted(igdbSlug));
|
||||
|
||||
Igdb.Game igdbGame = igdbWrapper.getGameBySlug(igdbSlug)
|
||||
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "Game with slug '%s' does not exist on IGDB.".formatted(igdbSlug)));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user