scan is not async anymore

This commit is contained in:
zurdi zurdo
2023-04-10 20:56:02 +02:00
parent 7c87c85d18
commit ccba083533
2 changed files with 5 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ import subprocess
from subprocess import CalledProcessError
from fastapi import FastAPI, Request
import uvicorn
import json
from logger.logger import log
from handler import igdbh, dbh
@@ -21,14 +22,13 @@ def startup() -> None:
pass
@app.put("/scan")
async def scan(req: Request, full_scan: bool=False, overwrite: bool=False) -> dict:
@app.get("/scan")
def scan(platforms: str, full_scan: bool=False, overwrite: bool=False) -> dict:
"""Scan platforms and roms and write them in database."""
log.info("complete scaning...")
fs.store_default_resources(overwrite)
data: dict = await req.json()
platforms: list[str] = data['platforms'] if data['platforms'] else fs.get_platforms()
platforms: list[str] = json.loads(platforms) if len(json.loads(platforms)) > 0 else fs.get_platforms()
for p_slug in platforms:
platform: Platform = fastapi.scan_platform(p_slug)
roms: list[dict] = fs.get_roms(p_slug, full_scan)

View File

@@ -35,9 +35,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+'&full_scan='+fullScan.value,{
platforms: platforms
}).then((response) => {
await axios.get('/api/scan?platforms='+JSON.stringify(platforms)+'&overwrite='+scanOverwrite.value+'&full_scan='+fullScan.value).then((response) => {
console.log("scan completed")
console.log(response.data)
emitter.emit('snackbarScan', {'msg': 'Scan completed successfully!', 'icon': 'mdi-check-bold', 'color': 'green'})