From 9f7d566fa5054f1c54536377a72f80ceaa511e23 Mon Sep 17 00:00:00 2001 From: Percentnineteen Date: Fri, 6 Jun 2025 15:45:42 -0500 Subject: [PATCH 1/3] don't just delete the m3u file for multi-part roms --- RomM/romm.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/RomM/romm.py b/RomM/romm.py index 8b28781..fe29929 100644 --- a/RomM/romm.py +++ b/RomM/romm.py @@ -609,14 +609,7 @@ def _update_roms_view(self): ( f"{glyphs.delete} Remove from device", 1, - lambda: os.remove( - os.path.join( - self.fs.get_platforms_storage_path( - selected_rom.platform_slug - ), - selected_rom.fs_name, - ) - ), + lambda: self._remove_rom_files(selected_rom), ), ) else: @@ -877,3 +870,22 @@ def update(self): self._update_contextual_menu() self._update_common() + + def _remove_rom_files(self, rom): + storage_path = self.fs.get_platforms_storage_path(rom.platform_slug) + + if rom.multi: + rom_list_path = os.path.join(storage_path, rom.fs_name + ".m3u") + if os.path.isfile(rom_list_path): + with open(rom_list_path, "r") as f: + for line in f: + filename = line.strip() + if filename: + full_path = os.path.join(storage_path, filename) + if os.path.isfile(full_path): + os.remove(full_path) + os.remove(rom_list_path) + else: + full_path = os.path.join(storage_path, rom.fs_name) + if os.path.isfile(full_path): + os.remove(full_path) From 586505945174ed6e04486c040bb243f883cf53f3 Mon Sep 17 00:00:00 2001 From: KN Date: Fri, 6 Jun 2025 17:15:02 -0500 Subject: [PATCH 2/3] Update RomM/romm.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- RomM/romm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RomM/romm.py b/RomM/romm.py index fe29929..e45715d 100644 --- a/RomM/romm.py +++ b/RomM/romm.py @@ -882,10 +882,10 @@ def _remove_rom_files(self, rom): filename = line.strip() if filename: full_path = os.path.join(storage_path, filename) - if os.path.isfile(full_path): + if os.path.commonpath([storage_path, full_path]) == storage_path and os.path.isfile(full_path): os.remove(full_path) os.remove(rom_list_path) else: full_path = os.path.join(storage_path, rom.fs_name) - if os.path.isfile(full_path): + if os.path.commonpath([storage_path, full_path]) == storage_path and os.path.isfile(full_path): os.remove(full_path) From 89cef904c0338dc74224a94bfcb44ad362aac17b Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Fri, 6 Jun 2025 22:33:32 -0400 Subject: [PATCH 3/3] run formatter --- RomM/romm.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/RomM/romm.py b/RomM/romm.py index e45715d..da68be7 100644 --- a/RomM/romm.py +++ b/RomM/romm.py @@ -5,6 +5,7 @@ import sdl2 import sdl2.ext +from models import Rom if os.path.exists(os.path.join(os.path.dirname(__file__), "__version__.py")): from __version__ import version @@ -871,10 +872,11 @@ def update(self): self._update_common() - def _remove_rom_files(self, rom): + def _remove_rom_files(self, rom: Rom): storage_path = self.fs.get_platforms_storage_path(rom.platform_slug) if rom.multi: + # Read the m3u file to get the list of ROMs under the .hidden folder rom_list_path = os.path.join(storage_path, rom.fs_name + ".m3u") if os.path.isfile(rom_list_path): with open(rom_list_path, "r") as f: @@ -882,10 +884,14 @@ def _remove_rom_files(self, rom): filename = line.strip() if filename: full_path = os.path.join(storage_path, filename) - if os.path.commonpath([storage_path, full_path]) == storage_path and os.path.isfile(full_path): + if os.path.commonpath( + [storage_path, full_path] + ) == storage_path and os.path.isfile(full_path): os.remove(full_path) os.remove(rom_list_path) else: full_path = os.path.join(storage_path, rom.fs_name) - if os.path.commonpath([storage_path, full_path]) == storage_path and os.path.isfile(full_path): + if os.path.commonpath( + [storage_path, full_path] + ) == storage_path and os.path.isfile(full_path): os.remove(full_path)