diff --git a/backend/src/handler/igdb_handler.py b/backend/src/handler/igdb_handler.py index 5ff4b2646..bb1283a71 100644 --- a/backend/src/handler/igdb_handler.py +++ b/backend/src/handler/igdb_handler.py @@ -64,7 +64,7 @@ def get_rom_details(self, file_name: str, p_igdb_id: int, r_igdb_id_search: str) except KeyError: pass - else: + else: #TODO: improve API calls to make only one search_term: str = unidecode.unidecode(file_name_no_tags) if p_igdb_id: try: diff --git a/backend/src/main.py b/backend/src/main.py index 45ca3d2c7..86685396c 100644 --- a/backend/src/main.py +++ b/backend/src/main.py @@ -75,7 +75,7 @@ async def platforms() -> dict: @app.put("/scan") -async def scan(req: Request, overwrite: bool=False) -> dict: +async def scan(req: Request, full_scan: bool=False, overwrite: bool=False) -> dict: """Scan platforms and roms and write them in database.""" log.info("complete scaning...") @@ -84,10 +84,10 @@ async def scan(req: Request, overwrite: bool=False) -> dict: platforms: list[str] = data['platforms'] if data['platforms'] else fs.get_platforms() for p_slug in platforms: platform: Platform = fastapi.scan_platform(p_slug) - roms: list[dict] = fs.get_roms(p_slug) + roms: list[dict] = fs.get_roms(p_slug, full_scan) for rom in roms: fastapi.scan_rom(platform, rom) - dbh.purge_roms(p_slug, roms) + dbh.purge_roms(p_slug, fs.get_roms(p_slug, True)) dbh.purge_platforms(fs.get_platforms()) return {'msg': 'success'} diff --git a/backend/src/utils/fastapi.py b/backend/src/utils/fastapi.py index 43140ffa0..b359b18f1 100644 --- a/backend/src/utils/fastapi.py +++ b/backend/src/utils/fastapi.py @@ -31,7 +31,7 @@ def scan_platform(p_slug: str) -> Platform: platform_attrs: dict = igdbh.get_platform_details(p_slug) platform_attrs['slug'] = p_slug platform_attrs['logo_path'] = '' - platform_attrs['n_roms'] = fs.get_roms(p_slug, only_amount=True) + platform_attrs['n_roms'] = fs.get_roms(p_slug, True, only_amount=True) log.info(f"Platform n_roms: {platform_attrs['n_roms']}") platform = Platform(**platform_attrs) dbh.add_platform(platform) diff --git a/backend/src/utils/fs.py b/backend/src/utils/fs.py index b72cbc9a9..58147bb77 100644 --- a/backend/src/utils/fs.py +++ b/backend/src/utils/fs.py @@ -7,6 +7,9 @@ from fastapi import HTTPException from config import user_config, LIBRARY_BASE_PATH, RESERVED_FOLDERS, DEFAULT_URL_COVER_L, DEFAULT_PATH_COVER_L, DEFAULT_URL_COVER_S, DEFAULT_PATH_COVER_S +from models.platform import Platform +from models.rom import Rom +from handler import dbh from logger.logger import log @@ -91,7 +94,7 @@ def parse_tags(file_name: str) -> tuple: return reg, rev, other_tags -def get_roms(p_slug: str, only_amount: bool = False) -> list[dict]: +def get_roms(p_slug: str, full_scan: bool, only_amount: bool = False) -> list[dict]: """Gets all filesystem roms for a platform Args: @@ -106,7 +109,10 @@ def get_roms(p_slug: str, only_amount: bool = False) -> list[dict]: if only_amount: return len(roms_files) + excluded_roms: list[str] = [rom.file_name for rom in dbh.get_roms(p_slug)] + for rom in roms_files: + if rom in excluded_roms and not full_scan: continue file_size: str = str(round(os.stat(f"{roms_path}/{rom}").st_size / (1024 * 1024), 2)) file_extension: str = rom.split('.')[-1] if '.' in rom else "" reg, rev, other_tags = parse_tags(rom) @@ -115,7 +121,7 @@ def get_roms(p_slug: str, only_amount: bool = False) -> list[dict]: log.info(f"Roms found for {p_slug}: {roms}") except IndexError: log.warning(f"Roms not found for {p_slug}") - if only_amount: return 0 + if only_amount: return 0 return roms diff --git a/frontend/src/components/Navigation.vue b/frontend/src/components/Navigation.vue index e047f766f..0bf5ceffa 100644 --- a/frontend/src/components/Navigation.vue +++ b/frontend/src/components/Navigation.vue @@ -10,6 +10,7 @@ const currentPlatform = ref(JSON.parse(localStorage.getItem('currentPlatform')) const platformsToScan = ref([]) const scanning = ref(false) const scanOverwrite = ref(false) +const fullScan = ref(false) const gettingRomsFlag = ref(false) const filter = ref('') const drawer = ref(null) @@ -33,7 +34,7 @@ async function scan() { toRaw(platformsToScan)._rawValue.forEach(p => {platforms.push(toRaw(p.slug))}) console.log(platforms) - await axios.put('/api/scan?overwrite='+scanOverwrite.value,{ + await axios.put('/api/scan?overwrite='+scanOverwrite.value+'&full_scan='+fullScan.value,{ platforms: platforms }).then((response) => { console.log("scan completed") @@ -103,12 +104,18 @@ getPlatforms() - - -

Scan

-

Scanning

- -
+ + + + +

Scan

+ +
+
+ + + +
diff --git a/frontend/src/components/RomDetails.vue b/frontend/src/components/RomDetails.vue index 39616c441..68e128b59 100644 --- a/frontend/src/components/RomDetails.vue +++ b/frontend/src/components/RomDetails.vue @@ -191,7 +191,7 @@ async function deleteRom() { - + @@ -230,7 +230,7 @@ async function deleteRom() { Cancel
- +