mirror of
https://github.com/rommapp/romm.git
synced 2026-12-03 18:43:23 +01:00
Move get_config outside of _create_game_element and pass it in, to prevent it being called on each loop
This commit is contained in:
@@ -26,12 +26,10 @@ class GamelistExporter:
|
||||
"""Format release date to YYYYMMDDTHHMMSS format"""
|
||||
return datetime.fromtimestamp(timestamp / 1000).strftime("%Y%m%dT%H%M%S")
|
||||
|
||||
def _create_game_element(self, rom: Rom, request: Request | None) -> Element:
|
||||
def _create_game_element(self, rom: Rom, request: Request | None, config) -> Element:
|
||||
"""Create a <game> element for a ROM"""
|
||||
game = Element("game")
|
||||
|
||||
config = cm.get_config()
|
||||
|
||||
# Basic game info
|
||||
if self.local_export:
|
||||
SubElement(game, "path").text = f"./{rom.fs_name}"
|
||||
@@ -187,12 +185,14 @@ class GamelistExporter:
|
||||
|
||||
roms = db_rom_handler.get_roms_scalar(platform_ids=[platform_id])
|
||||
|
||||
config = cm.get_config()
|
||||
|
||||
# Create root element
|
||||
root = Element("gameList")
|
||||
|
||||
for rom in roms:
|
||||
if rom and not rom.missing_from_fs and rom.fs_name != "gamelist.xml":
|
||||
game_element = self._create_game_element(rom, request=request)
|
||||
game_element = self._create_game_element(rom, request=request, config=config)
|
||||
root.append(game_element)
|
||||
|
||||
# Convert to XML string
|
||||
@@ -235,4 +235,4 @@ class GamelistExporter:
|
||||
return True
|
||||
except Exception as e:
|
||||
log.error(f"Failed to export gamelist.xml for platform {platform_id}: {e}")
|
||||
return False
|
||||
return False
|
||||
Reference in New Issue
Block a user