Skip to content

Keep ROM list positions on the card - #1942

Open
robcodedev wants to merge 2 commits into
OnionUI:v4.5-devfrom
robcodedev:persist-rom-positions
Open

Keep ROM list positions on the card#1942
robcodedev wants to merge 2 commits into
OnionUI:v4.5-devfrom
robcodedev:persist-rom-positions

Conversation

@robcodedev

@robcodedev robcodedev commented Sep 8, 2026

Copy link
Copy Markdown

Problem

MainUI stores per-folder list positions in /appconfigs/romwinidx.json, which lives on internal storage. Move a card to another device, or reflash one, and every position is lost with no way to carry them across.

What this does

Restores from $sysdir/config/romwinidx.json at boot and writes back on shutdown. If there is no copy on the card yet, the device file is removed, so the first boot after installing starts from a known state rather than inheriting whatever that device happened to have.

Unclean shutdowns

The write-back happens in check_off_order, so it is skipped on a crash or power loss. Restoring unconditionally would then overwrite the device file with an older card copy. restore_romwinidx touches config/.romwinidx_dirty and save_romwinidx removes it, so a mark surviving a boot means the last session ended uncleanly - in that case neither file is touched.

Problem with unclean shutdowns reported by @Amiga500 and fixed in new commit.

Known limitation

Positions from a session that ended uncleanly stay on the device and never reach the card, so they don't follow it to another device until the next clean shutdown.

Testing

Moved a card between two devices and confirmed positions follow it.

romwinidx.json lives in /appconfigs, on internal storage. Move the card
to another device and every list position is gone.

Copy it off the card at boot and back at shutdown. If there's no copy on
the card yet we remove the device file, so you start clean instead of
inheriting whatever that device happened to have.
Copilot AI added a commit to Amiga500/Onion that referenced this pull request Sep 9, 2026
…1943 OnionUI#1944 OnionUI#1945 OnionUI#1946 (runtime.sh, keymon, lt.lang)

Co-authored-by: Amiga500 <16525337+Amiga500@users.noreply.github.com>
save_romwinidx runs from check_off_order, so it is skipped when the
device crashes or loses power. The restore at boot then overwrote the
device file with an older card copy, throwing away every position
recorded since the last clean shutdown. Stock kept those.

restore_romwinidx now touches config/.romwinidx_dirty after running and
save_romwinidx removes it, so a mark surviving a boot means the last
session never reached a clean shutdown. Leave both files alone in that
case and let the next clean shutdown publish whatever the device has.

Not promoting the device file to the card there is deliberate: if the
card also moved, that would overwrite a good copy with a different
device's stale one.

A mark rather than comparing modification times, because mtime answers
which device was written to most recently rather than whether the last
session was clean, and those differ exactly when the card has moved.

Problem reported by @Amiga500 and fixed in this new commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant