From 01e2ca76a6eaab33a637c665ec9bf642030b9ec5 Mon Sep 17 00:00:00 2001 From: KaitoKid Date: Sat, 23 Nov 2024 14:43:02 -0800 Subject: [PATCH 1/6] Fix tinfoil issue with single rom in directory --- backend/endpoints/feeds.py | 4 ++-- backend/handler/filesystem/roms_handler.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/endpoints/feeds.py b/backend/endpoints/feeds.py index 40f305999..521c3a3f8 100644 --- a/backend/endpoints/feeds.py +++ b/backend/endpoints/feeds.py @@ -161,10 +161,10 @@ async def extract_titledb(roms: list[Rom]) -> dict[str, TinfoilFeedTitleDBSchema TinfoilFeedFileSchema( url=str( request.url_for( - "get_rom_content", id=rom.id, file_name=rom.file_name + "get_rom_content", id=rom.id, file_name=rom.files[0].get('filename') + "#" + rom.file_name ) ), - size=rom.file_size_bytes, + size=rom.rom.files[0].get('size'), ) for rom in roms ], diff --git a/backend/handler/filesystem/roms_handler.py b/backend/handler/filesystem/roms_handler.py index 347813996..dcee88bb4 100644 --- a/backend/handler/filesystem/roms_handler.py +++ b/backend/handler/filesystem/roms_handler.py @@ -348,7 +348,7 @@ def get_roms(self, platform_fs_slug: str) -> list[FSRom]: return [ FSRom( - multi=rom["multi"], + multi=False if len(files := self.get_rom_files(rom["file_name"], roms_file_path)) == 1 else rom["multi"], file_name=rom["file_name"], files=self.get_rom_files(rom["file_name"], roms_file_path), ) From 1da0dec00ffd394b8dd461698bd0c5adec962da1 Mon Sep 17 00:00:00 2001 From: Kai Date: Sun, 24 Nov 2024 02:51:53 -0800 Subject: [PATCH 2/6] Update feeds.py --- backend/endpoints/feeds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/endpoints/feeds.py b/backend/endpoints/feeds.py index 521c3a3f8..7693ff79c 100644 --- a/backend/endpoints/feeds.py +++ b/backend/endpoints/feeds.py @@ -164,7 +164,7 @@ async def extract_titledb(roms: list[Rom]) -> dict[str, TinfoilFeedTitleDBSchema "get_rom_content", id=rom.id, file_name=rom.files[0].get('filename') + "#" + rom.file_name ) ), - size=rom.rom.files[0].get('size'), + size=rom.files[0].get('size'), ) for rom in roms ], From e4d9c5e5511ce7346c7fc2f0cbfc08872b39f93a Mon Sep 17 00:00:00 2001 From: KaitoKid Date: Sun, 24 Nov 2024 03:02:45 -0800 Subject: [PATCH 3/6] Handle empty folder gracefully --- backend/endpoints/feeds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/endpoints/feeds.py b/backend/endpoints/feeds.py index 7693ff79c..d19671db1 100644 --- a/backend/endpoints/feeds.py +++ b/backend/endpoints/feeds.py @@ -166,7 +166,7 @@ async def extract_titledb(roms: list[Rom]) -> dict[str, TinfoilFeedTitleDBSchema ), size=rom.files[0].get('size'), ) - for rom in roms + for rom in roms if rom.files and len(rom.files) > 0 ], directories=[], success="RomM Switch Library", From d9dc3df54be474d0d01ffa6dadad33803127e50f Mon Sep 17 00:00:00 2001 From: KaitoKid Date: Sun, 24 Nov 2024 03:53:58 -0800 Subject: [PATCH 4/6] Update the rom file_name if it's nested in a directory so it can be fetched by downloader --- backend/handler/filesystem/roms_handler.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/handler/filesystem/roms_handler.py b/backend/handler/filesystem/roms_handler.py index dcee88bb4..59ed21a6b 100644 --- a/backend/handler/filesystem/roms_handler.py +++ b/backend/handler/filesystem/roms_handler.py @@ -349,8 +349,12 @@ def get_roms(self, platform_fs_slug: str) -> list[FSRom]: return [ FSRom( multi=False if len(files := self.get_rom_files(rom["file_name"], roms_file_path)) == 1 else rom["multi"], - file_name=rom["file_name"], - files=self.get_rom_files(rom["file_name"], roms_file_path), + file_name=( + f"{rom['file_name']}/{files[0].get('filename')}" + if len(files) == 1 and rom["file_name"] != files[0].get('filename') + else rom["file_name"] + ), + files=files, ) for rom in fs_roms ] From 864c0abc71df75b0e55c78dbdd525609adc515a7 Mon Sep 17 00:00:00 2001 From: KaitoKid Date: Sun, 24 Nov 2024 04:12:09 -0800 Subject: [PATCH 5/6] Roll back naming changes --- backend/endpoints/feeds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/endpoints/feeds.py b/backend/endpoints/feeds.py index d19671db1..51fbf919a 100644 --- a/backend/endpoints/feeds.py +++ b/backend/endpoints/feeds.py @@ -161,7 +161,7 @@ async def extract_titledb(roms: list[Rom]) -> dict[str, TinfoilFeedTitleDBSchema TinfoilFeedFileSchema( url=str( request.url_for( - "get_rom_content", id=rom.id, file_name=rom.files[0].get('filename') + "#" + rom.file_name + "get_rom_content", id=rom.id, file_name=rom.files[0].get('filename') ) ), size=rom.files[0].get('size'), From a32ba181f56352486b6edc466eaf79f15af19203 Mon Sep 17 00:00:00 2001 From: KaitoKid Date: Mon, 25 Nov 2024 02:46:09 -0800 Subject: [PATCH 6/6] Support rom folders with multiple files inside --- backend/endpoints/feeds.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/endpoints/feeds.py b/backend/endpoints/feeds.py index 51fbf919a..d82f05be8 100644 --- a/backend/endpoints/feeds.py +++ b/backend/endpoints/feeds.py @@ -161,12 +161,13 @@ async def extract_titledb(roms: list[Rom]) -> dict[str, TinfoilFeedTitleDBSchema TinfoilFeedFileSchema( url=str( request.url_for( - "get_rom_content", id=rom.id, file_name=rom.files[0].get('filename') + "get_rom_content", id=rom.id, file_name=file.get('filename') ) ), size=rom.files[0].get('size'), ) for rom in roms if rom.files and len(rom.files) > 0 + for file in rom.files ], directories=[], success="RomM Switch Library",