fixes from migration

This commit is contained in:
Georges-Antoine Assi
2025-01-15 21:56:24 -05:00
parent 696a1c6122
commit 0ef2e03a9e
7 changed files with 20 additions and 19 deletions

View File

@@ -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

View File

@@ -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),
},
)

View File

@@ -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

View File

@@ -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);

View File

@@ -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");

View File

@@ -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"),
);
}

View File

@@ -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}`
: "";