rommapp / romm

A beautiful, powerful, self-hosted rom manager
https://romm.app
GNU Affero General Public License v3.0
2.23k stars 93 forks source link

[Bug] App breaks when a platform has a folder with roms inside of it #1115

Closed SaraVieira closed 2 months ago

SaraVieira commented 2 months ago

RomM version v3.5.0-alpha.1 - Present in the master branch and not in the release branc

Describe the bug When you have a folder with roms inside of a platform folder it the request to get them fails with Internal server error

To Reproduce Create a structure similar to this

.
└── library/
    └── roms/
        ├── gba/
        │   ├── file.gba
        │   └── another.gba
        └── hacks/
            └── sonicexe.gba

Where you have a folder with roms inside a platform.

Expected behavior the page should open

Screenshots CleanShot 2024-08-25 at 10 24 59@2x

Desktop (please complete the following information):

Additional context Error showned in the terminal is:

  Input should be a valid dictionary [type=dict_type, input_value='Fire Emblem Souls of the Forest.7z', input_type=str]
    For further information visit https://errors.pydantic.dev/2.8/v/dict_type

and this file is one of the ones in the hacks folder.

Changing this fn in backend/endpoints/rom.py:

@protected_route(router.get, "/roms", ["roms.read"])
def get_roms(
    request: Request,
    platform_id: int | None = None,
    collection_id: int | None = None,
    search_term: str = "",
    limit: int | None = None,
    order_by: str = "name",
    order_dir: str = "asc",
) -> list[SimpleRomSchema]:
    """Get roms endpoint

    Args:
        request (Request): Fastapi Request object
        id (int, optional): Rom internal id

    Returns:
        list[SimpleRomSchema]: List of roms stored in the database
    """

    roms = db_rom_handler.get_roms(
        platform_id=platform_id,
        collection_id=collection_id,
        search_term=search_term.lower(),
        order_by=order_by.lower(),
        order_dir=order_dir.lower(),
        limit=limit,
    )
    return [SimpleRomSchema.from_orm_with_request(rom, request) for rom in roms]

To just return roms instead will make the issue be resolved, so its a types issue but I don't have enough python knowlage to fix it :/

gantoine commented 2 months ago

Seeing as you're on the alpha release, run a quick scan from the scan menu. This should rebuild the files list in the DB for each rom.

SaraVieira commented 2 months ago

I am an idiot and I am sorry

Thank you! That fixed it!