@@ -71,9 +71,10 @@ export class FilesService implements OnApplicationBootstrap {
7171 async onApplicationBootstrap ( ) {
7272 if ( configuration . TESTING . MOCK_FILES ) {
7373 this . logger . warn ( {
74- message : "Skipping File Indexer ." ,
74+ message : "Skipping File Watcher ." ,
7575 reason : "TESTING_MOCK_FILES is set to true." ,
7676 } ) ;
77+ this . indexAllFiles ( ) ;
7778 return ;
7879 }
7980
@@ -389,16 +390,21 @@ export class FilesService implements OnApplicationBootstrap {
389390
390391 const selectedVersion = selectDefaultGameVersion ( availableVersions ) ;
391392
392- this . applyVersionToGame ( gameToUpdate , selectedVersion ) ;
393- gameToUpdate . title = indexedGame . title ;
394- gameToUpdate . sort_title = this . gamesService . generateSortTitle (
393+ const gamePatch = Object . assign ( new GamevaultGame ( ) , { id } ) ;
394+ this . applyVersionToGame ( gamePatch , selectedVersion ) ;
395+ gamePatch . title = indexedGame . title ;
396+ gamePatch . sort_title = this . gamesService . generateSortTitle (
395397 indexedGame . title ,
396398 ) ;
397399
398- const updatedGame = await this . gamesService . save ( gameToUpdate ) ;
400+ // Persist only scalar game fields to avoid relation graph side effects.
401+ await this . gamesService . save ( gamePatch ) ;
402+ const updatedGame = await this . gamesService . findOneByGameIdOrFail ( id , {
403+ loadDeletedEntities : false ,
404+ } ) ;
399405 this . logger . log ( {
400406 message : `Updated game versions based on file changes.` ,
401- game : logGamevaultGame ( gameToUpdate ) ,
407+ game : logGamevaultGame ( updatedGame ) ,
402408 } ) ;
403409 return updatedGame ;
404410 }
@@ -932,16 +938,13 @@ export class FilesService implements OnApplicationBootstrap {
932938 await this . gameVersionRepository . softDelete ( staleVersionIds ) ;
933939 }
934940
935- const gameToUpdate = await this . gamesService . findOneByGameIdOrFail (
936- gameInDatabase . id ,
937- {
938- loadDeletedEntities : false ,
939- } ,
940- ) ;
941-
942941 const selectedVersion = selectDefaultGameVersion ( existingVersions ) ;
943- this . applyVersionToGame ( gameToUpdate , selectedVersion ) ;
944- await this . gamesService . save ( gameToUpdate ) ;
942+ const gamePatch = Object . assign ( new GamevaultGame ( ) , {
943+ id : gameInDatabase . id ,
944+ } ) ;
945+ this . applyVersionToGame ( gamePatch , selectedVersion ) ;
946+ // Persist only scalar game fields to avoid relation graph side effects.
947+ await this . gamesService . save ( gamePatch ) ;
945948 }
946949
947950 checkedGames . push ( gameInDatabase ) ;
0 commit comments