[GH-61] Fix manual mapping leading to duplicates in DB

This commit is contained in:
grimsi
2022-10-21 21:15:51 +02:00
parent 76ea2d81f6
commit 755611689e
3 changed files with 9 additions and 3 deletions
@@ -105,6 +105,8 @@ public class GameService {
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "Game with slug '%s' does not exist on IGDB.".formatted(slug)));
DetectedGame game = gameMapper.toDetectedGame(igdbGame, Path.of(unmappableFile.getPath()));
game.setConfirmedMatch(true);
game = detectedGameRepository.save(game);
unmappableFileRepository.delete(unmappableFile);
@@ -117,8 +119,12 @@ public class GameService {
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "Game with slug '%s' does not exist on IGDB.".formatted(slug)));
DetectedGame game = gameMapper.toDetectedGame(igdbGame, Path.of(existingGame.getPath()));
game.setConfirmedMatch(true);
game = detectedGameRepository.save(game);
detectedGameRepository.delete(existingGame);
return game;
}
}