diff --git a/.gitignore b/.gitignore index f570fd1f7..3a1d24cf5 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,8 @@ coverage # Editor directories and files .vscode +.zed +pyrightconfig.json !.vscode/extensions.json !.vscode/settings.json !.vscode/tasks.json diff --git a/backend/endpoints/rom.py b/backend/endpoints/rom.py index c7d1f1301..97d1cece7 100644 --- a/backend/endpoints/rom.py +++ b/backend/endpoints/rom.py @@ -50,7 +50,14 @@ async def add_rom(request: Request): detail="No platform ID or filename provided", ) from None - platform_fs_slug = db_platform_handler.get_platform(int(platform_id)).fs_slug + db_platform = db_platform_handler.get_platform(int(platform_id)) + if not db_platform: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail="Platform not found", + ) from None + + platform_fs_slug = db_platform.fs_slug roms_path = fs_rom_handler.build_upload_file_path(platform_fs_slug) log.info(f"Uploading file to {platform_fs_slug}") diff --git a/frontend/src/components/common/Game/Dialog/UploadRom.vue b/frontend/src/components/common/Game/Dialog/UploadRom.vue index 43e73c53b..5e210eaf7 100644 --- a/frontend/src/components/common/Game/Dialog/UploadRom.vue +++ b/frontend/src/components/common/Game/Dialog/UploadRom.vue @@ -52,9 +52,7 @@ emitter?.on("showUploadRomDialog", (platformWhereUpload) => { }) .catch(({ response, message }) => { emitter?.emit("snackbarShow", { - msg: `Unable to upload roms: ${ - response?.data?.detail || response?.statusText || message - }`, + msg: `Unable to upload roms: ${response?.data?.detail || response?.statusText || message}`, icon: "mdi-close-circle", color: "red", timeout: 4000, @@ -101,13 +99,15 @@ async function uploadRoms() { platformId: platformId, }) .then((responses: PromiseSettledResult[]) => { - uploadStore.clear(); - const successfulUploads = responses.filter( - (d) => d.status == "fulfilled" + (d) => d.status == "fulfilled", ); const failedUploads = responses.filter((d) => d.status == "rejected"); + if (failedUploads.length == 0) { + uploadStore.clearAll(); + } + if (successfulUploads.length == 0) { return emitter?.emit("snackbarShow", { msg: `All files skipped, nothing to upload.`, @@ -137,9 +137,7 @@ async function uploadRoms() { }) .catch(({ response, message }) => { emitter?.emit("snackbarShow", { - msg: `Unable to upload roms: ${ - response?.data?.detail || response?.statusText || message - }`, + msg: `Unable to upload roms: ${response?.data?.detail || response?.statusText || message}`, icon: "mdi-close-circle", color: "red", timeout: 4000, @@ -156,7 +154,7 @@ function triggerFileInput() { function removeRomFromList(romName: string) { filesToUpload.value = filesToUpload.value.filter( - (rom) => rom.name !== romName + (rom) => rom.name !== romName, ); } diff --git a/frontend/src/components/common/UploadInProgress.vue b/frontend/src/components/common/UploadInProgress.vue index c851a9cf4..f096ab871 100644 --- a/frontend/src/components/common/UploadInProgress.vue +++ b/frontend/src/components/common/UploadInProgress.vue @@ -10,6 +10,10 @@ const uploadStore = storeUpload(); const { files } = storeToRefs(uploadStore); const show = ref(false); +function clearFinished() { + uploadStore.clearFinished(); +} + watch(files, (newList) => { show.value = newList.length > 0; }); @@ -30,41 +34,64 @@ watch(files, (newList) => { - - {{ file.filename }} - - -