Skip to content

Commit

Permalink
Only delete the types that are enabled in the config
Browse files Browse the repository at this point in the history
  • Loading branch information
milouk committed Oct 3, 2024
1 parent d3b709d commit ea99b73
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def get_roms(self, system: str) -> list[Rom]:
roms.append(rom)
return roms

def delete_all_files_in_directory(self, filenames, directory_path):
def delete_files_in_directory(self, filenames, directory_path):
directory = Path(directory_path)
if directory.is_dir():
for file in directory.iterdir():
Expand All @@ -132,8 +132,15 @@ def delete_system_media(self) -> None:
system = self.systems_mapping.get(selected_system)
if system:
roms = [rom.name for rom in self.get_roms(selected_system)]
for media_type in ["box", "preview", "synopsis"]:
self.delete_all_files_in_directory(roms, system.get(media_type, ""))
media_types = []
if self.box_enabled:
media_types.append("box")
if self.preview_enabled:
media_types.append("preview")
if self.synopsis_enabled:
media_types.append("synopsis")
for media_type in media_types:
self.delete_files_in_directory(roms, system.get(media_type, ""))

def draw_available_systems(self, available_systems: List[str]) -> None:
max_elem = 11
Expand Down

0 comments on commit ea99b73

Please sign in to comment.