Extract 3DS save location via sigil folder-split usage

The 3DS nests its save under two directory levels, so sigil reports it as
a '/'-separated save_id (00040000/00033500) flagged with usage=folder-split
rather than a flat id. Add SaveUsage.FOLDER_SPLIT, migrate the saveusage
enum (0106), regenerate the frontend SaveUsage type, and bump the sigil
pin to 98f3c62.
This commit is contained in:
nendo
2026-07-29 12:45:31 +09:00
parent 3f91f0d20b
commit 0c88dfdfe0
6 changed files with 96 additions and 3 deletions

View File

@@ -81,7 +81,7 @@ ENV PATH="/app/.venv/bin:${PATH}"
# Build and install sigil (optional, for title ID extraction)
# Placed after `uv sync` because the extension is compiled with the venv's
# Python so the ABI matches.
ARG SIGIL_VERSION=45fcd54c1e6e18b63f83a70b8d86a4f93fb53340
ARG SIGIL_VERSION=98f3c626eecac48aa99209414d88a15ebe9b70c4
RUN git clone --recurse-submodules https://github.com/rommforge/argosy-sigil.git /tmp/argosy-sigil
WORKDIR /tmp/argosy-sigil
RUN git checkout "${SIGIL_VERSION}" \

View File

@@ -0,0 +1,59 @@
"""Add FOLDER_SPLIT to the saveusage enum (3DS saves nest the id across
two directory levels).
Revision ID: 0106_sigil_folder_split
Revises: 0105_sigil_title_version
Create Date: 2026-07-29 00:00:00.000000
"""
import sqlalchemy as sa
from alembic import op
from utils.database import is_postgresql
# revision identifiers, used by Alembic.
revision = "0106_sigil_folder_split"
down_revision = "0105_sigil_title_version"
branch_labels = None
depends_on = None
SAVE_USAGE_VALUES = (
"FOLDER_EXACT",
"FOLDER_PREFIX",
"FILE_EXACT",
"FILE_PREFIX",
"FOLDER_SPLIT",
)
def upgrade() -> None:
connection = op.get_bind()
if is_postgresql(connection):
# ALTER TYPE ... ADD VALUE must run outside alembic's transaction.
with op.get_context().autocommit_block():
op.execute("ALTER TYPE saveusage ADD VALUE IF NOT EXISTS 'FOLDER_SPLIT'")
else:
save_usage_enum = sa.Enum(*SAVE_USAGE_VALUES, name="saveusage")
with op.batch_alter_table("roms", schema=None) as batch_op:
batch_op.alter_column("save_usage", type_=save_usage_enum, nullable=True)
def downgrade() -> None:
# PostgreSQL cannot drop enum values; leave FOLDER_SPLIT in place. On
# MariaDB, narrow the enum back after clearing any rows that used it.
connection = op.get_bind()
if is_postgresql(connection):
return
op.execute("UPDATE roms SET save_usage = NULL WHERE save_usage = 'FOLDER_SPLIT'")
reverted_enum = sa.Enum(
"FOLDER_EXACT",
"FOLDER_PREFIX",
"FILE_EXACT",
"FILE_PREFIX",
name="saveusage",
)
with op.batch_alter_table("roms", schema=None) as batch_op:
batch_op.alter_column("save_usage", type_=reverted_enum, nullable=True)

View File

@@ -89,6 +89,7 @@ class SaveUsage(enum.StrEnum):
FOLDER_PREFIX = "folder-prefix"
FILE_EXACT = "file-exact"
FILE_PREFIX = "file-prefix"
FOLDER_SPLIT = "folder-split"
class SiblingRom(BaseModel):

View File

@@ -1528,6 +1528,39 @@ class TestSigilTitleIdExtraction:
assert parsed.save_id == "ULUS10041"
assert parsed.save_usage == SaveUsage.FOLDER_PREFIX
@pytest.mark.asyncio
async def test_3ds_extraction_maps_folder_split_usage(
self, tmp_path: Path, config: Config
):
platform = Platform(name="Nintendo 3DS", slug="3ds", fs_slug="3ds")
handler = self._make_handler(tmp_path)
rom = self._make_single_file_rom(tmp_path, platform, "Game.3ds")
mock_extract = AsyncMock(
return_value=SigilExtractionResult(
title_id="0004000000033500",
# save_id carries the on-disk split, not the flat id.
save_id="00040000/00033500",
usage="folder-split",
)
)
with pytest.MonkeyPatch.context() as m:
m.setattr("handler.filesystem.roms_handler.cm.get_config", lambda: config)
with (
patch(self.SIGIL_PATCH_TARGET, mock_extract),
patch(
"adapters.services.rahasher.RAHasherService.calculate_hash",
new_callable=AsyncMock,
return_value="",
),
):
parsed = await handler.get_rom_files(rom)
assert parsed.rom_files[0].save_id == "00040000/00033500"
assert parsed.save_id == "00040000/00033500"
assert parsed.save_usage == SaveUsage.FOLDER_SPLIT
@pytest.mark.asyncio
async def test_non_sigil_platform_skips_extraction(
self, tmp_path: Path, config: Config

View File

@@ -116,7 +116,7 @@ RUN apk add --no-cache \
make \
musl-dev
ARG SIGIL_VERSION=45fcd54c1e6e18b63f83a70b8d86a4f93fb53340
ARG SIGIL_VERSION=98f3c626eecac48aa99209414d88a15ebe9b70c4
RUN git clone --recurse-submodules https://github.com/rommforge/argosy-sigil.git && \
cd ./argosy-sigil && \

View File

@@ -2,4 +2,4 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type SaveUsage = 'folder-exact' | 'folder-prefix' | 'file-exact' | 'file-prefix';
export type SaveUsage = 'folder-exact' | 'folder-prefix' | 'file-exact' | 'file-prefix' | 'folder-split';