mirror of
https://github.com/rommapp/romm.git
synced 2026-11-28 17:48:31 +01:00
Teaches the streaming endpoints the webstation activate/exit contract alongside the existing per-emulator broker mods, lets one container serve a pool of platforms, and claims the first free container from that pool. Sessions now sync save states, save archives and whole memory cards back into the RomM library on release, keep every capture as browsable history, and record the disc a state was taken on so a resume remounts it. Container adoptions track a card the container already held so it is never wiped without asking.
35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
from datetime import datetime
|
|
from typing import Literal
|
|
|
|
from sqlalchemy import TIMESTAMP, ForeignKey, String, func
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from models.base import BaseModel
|
|
|
|
# The only two decisions: the container's pre-existing card was imported, or
|
|
# it was wiped. The single source of truth for both the column and its writers.
|
|
AdoptionOutcome = Literal["adopt", "discard"]
|
|
|
|
|
|
class StreamingContainerAdoption(BaseModel):
|
|
"""One row per streaming container, recording the one-time decision about
|
|
the card that was already on it when memory_card_sync was enabled.
|
|
|
|
Keyed by container rather than by card: a card can be deleted, and if the
|
|
marker went with it the next user would be offered a container card that by
|
|
then holds someone else's saves.
|
|
"""
|
|
|
|
__tablename__ = "streaming_container_adoptions"
|
|
__table_args__ = {"extend_existing": True}
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
|
container_key: Mapped[str] = mapped_column(String(length=512), unique=True)
|
|
outcome: Mapped[AdoptionOutcome] = mapped_column(String(length=16))
|
|
decided_by_user_id: Mapped[int | None] = mapped_column(
|
|
ForeignKey("users.id", ondelete="SET NULL"), nullable=True
|
|
)
|
|
decided_at: Mapped[datetime] = mapped_column(
|
|
TIMESTAMP(timezone=True), server_default=func.now()
|
|
)
|