From 0ef2e03a9e8d03d6305eeafea027e752c28cc8a3 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Wed, 15 Jan 2025 21:56:24 -0500 Subject: [PATCH] fixes from migration --- ...e_and_hashes.py => 0031_rom_file_and_hashes.py} | 8 ++++---- backend/endpoints/rom.py | 7 ++++--- backend/endpoints/screenshots.py | 4 ++-- frontend/src/components/Details/ActionBar.vue | 2 +- .../components/common/Game/Dialog/ShowQRCode.vue | 2 +- frontend/src/utils/index.ts | 14 +++++++------- frontend/src/views/Player/EmulatorJS/Player.vue | 2 +- 7 files changed, 20 insertions(+), 19 deletions(-) rename backend/alembic/versions/{0030_rom_file_and_hashes.py => 0031_rom_file_and_hashes.py} (97%) diff --git a/backend/alembic/versions/0030_rom_file_and_hashes.py b/backend/alembic/versions/0031_rom_file_and_hashes.py similarity index 97% rename from backend/alembic/versions/0030_rom_file_and_hashes.py rename to backend/alembic/versions/0031_rom_file_and_hashes.py index a29315d83..1e1bbd6ee 100644 --- a/backend/alembic/versions/0030_rom_file_and_hashes.py +++ b/backend/alembic/versions/0031_rom_file_and_hashes.py @@ -1,7 +1,7 @@ """empty message -Revision ID: 0030_rom_file_and_hashes -Revises: 0029_platforms_custom_name +Revision ID: 0031_rom_file_and_hashes +Revises: 0030_user_email_null Create Date: 2024-12-19 23:16:11.053536 """ @@ -15,8 +15,8 @@ from handler.scan_handler import ScanType from sqlalchemy.dialects import mysql # revision identifiers, used by Alembic. -revision = "0030_rom_file_and_hashes" -down_revision = "0029_platforms_custom_name" +revision = "0031_rom_file_and_hashes" +down_revision = "0030_user_email_null" branch_labels = None depends_on = None diff --git a/backend/endpoints/rom.py b/backend/endpoints/rom.py index f2b6c4797..9d7d29fe9 100644 --- a/backend/endpoints/rom.py +++ b/backend/endpoints/rom.py @@ -288,13 +288,14 @@ async def get_rom_content( if not rom.multi: # Serve the file directly in development mode for emulatorjs if DEV_MODE: + rom_path = f"{LIBRARY_BASE_PATH}/{rom.full_path}" return FileResponse( path=rom_path, - filename=rom.file_name, + filename=rom.fs_name, headers={ - "Content-Disposition": f'attachment; filename="{quote(rom.file_name)}"', + "Content-Disposition": f'attachment; filename="{quote(rom.fs_name)}"', "Content-Type": "application/octet-stream", - "Content-Length": str(rom.file_size_bytes), + "Content-Length": str(rom.fs_size_bytes), }, ) diff --git a/backend/endpoints/screenshots.py b/backend/endpoints/screenshots.py index 5b4ba2232..81f92eb44 100644 --- a/backend/endpoints/screenshots.py +++ b/backend/endpoints/screenshots.py @@ -1,7 +1,7 @@ from decorators.auth import protected_route -from exceptions.endpoint_exceptions import RomNotFoundInDatabaseException from endpoints.responses.assets import ScreenshotSchema, UploadedScreenshotsResponse -from fastapi import File, Request, UploadFile, status +from exceptions.endpoint_exceptions import RomNotFoundInDatabaseException +from fastapi import File, Request, UploadFile from handler.auth.constants import Scope from handler.database import db_rom_handler, db_screenshot_handler from handler.filesystem import fs_asset_handler diff --git a/frontend/src/components/Details/ActionBar.vue b/frontend/src/components/Details/ActionBar.vue index 9f63d4e13..edf51733e 100644 --- a/frontend/src/components/Details/ActionBar.vue +++ b/frontend/src/components/Details/ActionBar.vue @@ -49,7 +49,7 @@ const is3DSRom = computed(() => { async function copyDownloadLink(rom: DetailedRom) { const downloadLink = getDownloadLink({ rom, - files: downloadStore.fileIDsToDownload, + fileIDs: downloadStore.fileIDsToDownload, }); if (navigator.clipboard && window.isSecureContext) { await navigator.clipboard.writeText(downloadLink); diff --git a/frontend/src/components/common/Game/Dialog/ShowQRCode.vue b/frontend/src/components/common/Game/Dialog/ShowQRCode.vue index d0f5a16a3..cb32e871a 100644 --- a/frontend/src/components/common/Game/Dialog/ShowQRCode.vue +++ b/frontend/src/components/common/Game/Dialog/ShowQRCode.vue @@ -22,7 +22,7 @@ emitter?.on("showQRCodeDialog", async (romToView: SimpleRom) => { const downloadLink = getDownloadLink({ rom: romToView, - files: is3DSFile ? [] : [matchingFiles[0].filename], + fileIDs: is3DSFile ? [] : [matchingFiles[0].id], }); const qrCode = document.getElementById("qr-code"); diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts index d7f119bd3..76e6351b1 100644 --- a/frontend/src/utils/index.ts +++ b/frontend/src/utils/index.ts @@ -1,7 +1,7 @@ import cronstrue from "cronstrue"; import type { SimpleRom } from "@/stores/roms"; import type { Heartbeat } from "@/stores/heartbeat"; -import type { RomFile, RomUserStatus } from "@/__generated__"; +import type { RomFileSchema, RomUserStatus } from "@/__generated__"; /** * Views configuration object. @@ -102,12 +102,12 @@ export function getDownloadPath({ export function getDownloadLink({ rom, - files = [], + fileIDs = [], }: { rom: SimpleRom; - files?: string[]; + fileIDs?: number[]; }) { - return `${window.location.origin}${encodeURI(getDownloadPath({ rom, files }))}`; + return `${window.location.origin}${encodeURI(getDownloadPath({ rom, fileIDs }))}`; } /** @@ -584,12 +584,12 @@ export function getStatusKeyForText(text: string) { } export function is3DSCIAFile(rom: SimpleRom): boolean { - return rom.file_extension.toLowerCase() == "cia"; + return rom.fs_extension.toLowerCase() == "cia"; } -export function get3DSCIAFiles(rom: SimpleRom): RomFile[] { +export function get3DSCIAFiles(rom: SimpleRom): RomFileSchema[] { return rom.files.filter((file) => - file.filename.toLowerCase().endsWith(".cia"), + file.file_name.toLowerCase().endsWith(".cia"), ); } diff --git a/frontend/src/views/Player/EmulatorJS/Player.vue b/frontend/src/views/Player/EmulatorJS/Player.vue index 2e9a2d251..0f60de963 100644 --- a/frontend/src/views/Player/EmulatorJS/Player.vue +++ b/frontend/src/views/Player/EmulatorJS/Player.vue @@ -62,7 +62,7 @@ window.EJS_controlScheme = getControlSchemeForPlatform( ); window.EJS_threads = areThreadsRequiredForEJSCore(window.EJS_core); window.EJS_gameID = romRef.value.id; -window.EJS_gameUrl = `/api/roms/${romRef.value.id}/content/${romRef.value.file_name}`; +window.EJS_gameUrl = `/api/roms/${romRef.value.id}/content/${romRef.value.fs_name}`; window.EJS_biosUrl = props.bios ? `/api/firmware/${props.bios.id}/content/${props.bios.file_name}` : "";