Skip to content

saves: import without --out writes to LEONIDA_SAVE_DIR, where the runtime reads - #7567

Open
elReque05 wants to merge 1 commit into
ItsNotRexed:mainfrom
elReque05:fix/saves-import-leonida-save-dir
Open

elReque05 wants to merge 1 commit into
ItsNotRexed:mainfrom
elReque05:fix/saves-import-leonida-save-dir

Conversation

@elReque05

Copy link
Copy Markdown

Claim: #7496 (comment) (new BUILD item)

Problem

The runtime's offline XGameSave (save_root() in runtime/shims/xgameruntime_gamesave.cpp:169-176) keeps saves in
LEONIDA_SAVE_DIR and falls back to %LOCALAPPDATA%\Leonida\saves only when that variable is unset or empty.
tools/saves.py import without --out always used the fallback (tools/saves.py:614). With LEONIDA_SAVE_DIR set,
the import exited 0 and printed wrote N blobs, but into a folder the runtime never reads. docs/saves.md says the
import writes into the runtime's layout; the existing import tests always pass --out, so the default was untested.

Repro on main (synthetic ASAV, no game files): LEONIDA_SAVE_DIR=<A>, LOCALAPPDATA=<B>,
python -I tools/saves.py import <folder> → <A> stays empty, the blob lands in <B>\Leonida\saves\local-user\....

Fix

The default output folder is now, in order:

  1. --out, when given (unchanged);
  2. LEONIDA_SAVE_DIR, when set and not empty — the same test the shim makes;
  3. %LOCALAPPDATA%\Leonida\saves (unchanged).

default_save_root() holds that rule; the usage text and docs/saves.md say so.

Files

  • tools/saves.py — default_save_root(), used by import when --out is absent; usage text.
  • tests/test_saves.py — ImportDefaultFolderTest: the LEONIDA_SAVE_DIR default, --out winning over it, and
    an unset or empty variable falling back to LOCALAPPDATA. Every folder is temporary and LOCALAPPDATA is
    redirected, so no real save folder is touched.
  • docs/saves.md — one sentence on the default folder.

Tests

Windows 11, Python 3.13.5. CPU-only; no GPU, Vulkan or game files involved.

  • python -I tests/test_saves.py ImportDefaultFolderTest on main's tools/saves.py:
    test_leonida_save_dir_is_the_default fails; the --out and unset/empty cases pass (they guard existing
    behaviour).
  • Same class with this change: 3/3 pass.
  • python -I tests/test_saves.py: 73 tests OK, 3 skipped (main: 70 OK, the same 3 skipped).
  • python -I tests/test_saves_import_args.py: OK.
  • python -I scripts/check_no_game_data.py tools/saves.py tests/test_saves.py docs/saves.md: exit 0.

Limitations

AI-assisted (Claude Code): the analysis, code, tests and this description were written with Claude Code and reviewed
before submission.

…time reads

The runtime's offline XGameSave (save_root() in
runtime/shims/xgameruntime_gamesave.cpp) keeps saves in LEONIDA_SAVE_DIR and
falls back to %LOCALAPPDATA%\Leonida\saves only when that variable is unset or
empty. `saves.py import` without --out always wrote to the fallback, so with
LEONIDA_SAVE_DIR set it reported "wrote N blobs" into a folder the runtime
never reads.

The default is now --out, else LEONIDA_SAVE_DIR when set and not empty, else
%LOCALAPPDATA%\Leonida\saves. Three regression tests (ImportDefaultFolderTest)
run in temporary folders with LOCALAPPDATA redirected; the LEONIDA_SAVE_DIR
case fails before this change. The usage text and docs/saves.md say so.

AI-assisted (Claude Code).
@morodirule

Copy link
Copy Markdown

Tested 2c5af33 on Arch Linux, Python 3.14.10, CPU only: pass — tests/test_saves.py 73/73 OK (1 skipped). Negative control: tool swapped to merge-base → exactly 1 failure (the LEONIDA_SAVE_DIR default test); restored, green again. No game files, no GPU. AI-assisted.

@Desamodeth Desamodeth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified 2c5af33a on native Windows x64 (MSVC 19.44, Release). I imported a synthetic ASAV with the CLI, then launched a separate guest with gta6rt --run and read the named blob through XGameSave. The parent importer exited 0 with a custom save root set, but the guest got E_GS_BLOB_NOT_FOUND; the bytes were in the fallback folder.

On this head the guest read the exact input bytes from an absolute Unicode save root, and from the fallback with the variable unset or empty. With --out, only the explicit folder received the import, and pointing the guest there returned the same bytes. All paths were temporary. The saves and import-argument suites had 71 passes and 3 platform skips. CPU only, AI-assisted.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 2c5af33 merged with main dde82f2 on Linux/Python 3.12.16: pass

Merge is clean (tools/saves.py, docs/saves.md, tests/test_saves.py). import without --out now uses default_save_root(): LEONIDA_SAVE_DIR when set and not empty, else %LOCALAPPDATA%\Leonida\saves, matching the shim's save_root() as the docstring says; the docs and usage text were updated to match.

  • python -I tests/test_saves.py: Ran 73 tests, OK (skipped=1, a Windows directory-junction test).
  • Negative control (tools/saves.py restored from upstream/main): Ran 73 tests, FAILED (failures=1): test_leonida_save_dir_is_the_default (False is not true), so the new test discriminates.
  • tests/test_docs_*.py with the PR's docs/saves.md: only test_docs_cli_flags (docs/embedded_shaders.md:372) and test_docs_links (docs/dev-tools.md) fail, neither in files this PR touches; the rest are OK.

@airp1ane

Copy link
Copy Markdown
Contributor

Tested 2c5af33 on Windows 11, Python 3.15.2, NVIDIA RTX 4060 Ti (driver 621.24; CPU-only checks, no game files, no GPU/llvm-mc/MSVC used): pass.

Ran the test files this PR adds or changes, from a clean checkout of the PR head: test_saves.py - all exit 0.

AI-assisted (Claude Code).

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.

5 participants