cleanup archive member

This commit is contained in:
Georges-Antoine Assi
2026-05-29 20:54:32 -04:00
parent 19d50e86b9
commit 69e2373453
8 changed files with 32 additions and 15 deletions

View File

@@ -18,7 +18,7 @@ from handler.metadata.moby_handler import MobyMetadata
from handler.metadata.ra_handler import RAMetadata
from handler.metadata.ss_handler import SSMetadata
from models.collection import Collection
from models.rom import Rom, RomFileCategory, RomUserStatus
from models.rom import Rom, RomArchiveMember, RomFileCategory, RomUserStatus
from .base import BaseModel, UTCDatetime
@@ -147,14 +147,6 @@ class RomUserSchema(BaseModel):
return rom_user_schema_factory()
class ArchiveMemberSchema(TypedDict):
name: str
size: int
crc_hash: str
md5_hash: str
sha1_hash: str
class RomFileSchema(BaseModel):
model_config = ConfigDict(from_attributes=True)
@@ -172,7 +164,7 @@ class RomFileSchema(BaseModel):
sha1_hash: str | None
ra_hash: str | None
chd_sha1_hash: str | None
archive_members: list[ArchiveMemberSchema] | None
archive_members: list[RomArchiveMember] | None
category: RomFileCategory | None

View File

@@ -715,7 +715,8 @@ class SSHandler(MetadataHandler):
rom_size_bytes=fs_size_bytes,
rom_name=(
first_file.archive_members[0]["name"]
if first_file.archive_members and len(first_file.archive_members) == 1
if first_file.archive_members is not None
and len(first_file.archive_members) == 1
else first_file.file_name
),
rom_type=_get_rom_type(first_file),

View File

@@ -4,7 +4,7 @@ import copy
import enum
from datetime import datetime
from functools import cached_property
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, TypedDict
from sqlalchemy import (
TIMESTAMP,
@@ -64,6 +64,14 @@ class SiblingRom(BaseModel):
)
class RomArchiveMember(TypedDict):
name: str
size: int
crc_hash: str
md5_hash: str
sha1_hash: str
class RomFile(BaseModel):
__tablename__ = "rom_files"
@@ -80,7 +88,7 @@ class RomFile(BaseModel):
sha1_hash: Mapped[str | None] = mapped_column(String(100))
ra_hash: Mapped[str | None] = mapped_column(String(100))
chd_sha1_hash: Mapped[str | None] = mapped_column(String(100))
archive_members: Mapped[list[dict[str, Any]] | None] = mapped_column(
archive_members: Mapped[list[RomArchiveMember] | None] = mapped_column(
CustomJSON(), default=None, nullable=True
)
category: Mapped[RomFileCategory | None] = mapped_column(

View File

@@ -94,6 +94,7 @@ export type { RAProgression } from './models/RAProgression';
export type { RAUserGameProgression } from './models/RAUserGameProgression';
export type { RegionBreakdownItem } from './models/RegionBreakdownItem';
export type { Role } from './models/Role';
export type { RomArchiveMember } from './models/RomArchiveMember';
export type { RomFileCategory } from './models/RomFileCategory';
export type { RomFileSchema } from './models/RomFileSchema';
export type { RomFiltersDict } from './models/RomFiltersDict';

View File

@@ -2,4 +2,4 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type MetadataMediaType = 'bezel' | 'box2d' | 'box2d_back' | 'box3d' | 'miximage' | 'physical' | 'screenshot' | 'title_screen' | 'marquee' | 'logo' | 'fanart' | 'video' | 'video_normalized' | 'manual';
export type MetadataMediaType = 'bezel' | 'box2d' | 'box2d_back' | 'box3d' | 'miximage' | 'miximage_v2' | 'physical' | 'screenshot' | 'title_screen' | 'marquee' | 'logo' | 'fanart' | 'video' | 'video_normalized' | 'manual';

View File

@@ -0,0 +1,12 @@
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type RomArchiveMember = {
name: string;
size: number;
crc_hash: string;
md5_hash: string;
sha1_hash: string;
};

View File

@@ -2,6 +2,7 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { RomArchiveMember } from './RomArchiveMember';
import type { RomFileCategory } from './RomFileCategory';
export type RomFileSchema = {
id: number;
@@ -18,7 +19,7 @@ export type RomFileSchema = {
sha1_hash: (string | null);
ra_hash: (string | null);
chd_sha1_hash: (string | null);
archive_members: null;
archive_members: (Array<RomArchiveMember> | null);
category: (RomFileCategory | null);
};

View File

@@ -15,6 +15,7 @@ export type RomSSMetadata = {
manual_url?: (string | null);
marquee_url?: (string | null);
miximage_url?: (string | null);
miximage_v2_url?: (string | null);
physical_url?: (string | null);
screenshot_url?: (string | null);
steamgrid_url?: (string | null);
@@ -26,6 +27,7 @@ export type RomSSMetadata = {
box3d_path?: (string | null);
fanart_path?: (string | null);
miximage_path?: (string | null);
miximage_v2_path?: (string | null);
physical_path?: (string | null);
marquee_path?: (string | null);
logo_path?: (string | null);