File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
main-ui/menus/games/utils Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -71,15 +71,29 @@ def load_from_file(self):
7171
7272 with open (self .entries_file , 'r' ) as f :
7373 data = json .load (f )
74- self ._entries = [RomsListEntry (** entry ) for entry in data ]
74+ validated_entries = []
75+ for entry_data in data :
76+ entry = RomsListEntry (** entry_data )
77+ if os .path .exists (entry .rom_file_path ):
78+ validated_entries .append (entry )
79+ else :
80+ PyUiLogger .get_logger ().warning (
81+ f"ROM file not found, removing from list: { entry .rom_file_path } "
82+ )
83+
84+ self ._entries = validated_entries
7585 self ._entries_dict = {
7686 self ._entry_key (entry .rom_file_path , entry .game_system_name ): entry
7787 for entry in self ._entries
7888 }
7989
90+ # Save back the validated list in case some entries were removed
91+ self .save_to_file ()
92+
8093 except Exception as e :
8194 PyUiLogger .get_logger ().error (f"Failed to load entries: { e } " )
8295
96+
8397 def get_games (self ) -> List [RomInfo ]:
8498 return self .rom_info_list
8599
You can’t perform that action at this time.
0 commit comments