HLE: honor available disk space in storage prompts #3190

Open
github-bot wants to merge 1 commit from github-bot/gh-3190 into main AGit
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 11:31 UTC · original
andrewpozdnakov7-jpg:codex2/pls-available-space → main · +48 −2 · 1 files · 1 commits · open

Problem

The persistent local storage prompt completes immediately. It currently compares the request with the remaining quota, even when the storage query says the host disk can supply fewer bytes. A title can receive S_OK and then retry an operation with the same insufficient space.

Use the available_free value already calculated by the storage query. This accounts for both the remaining quota and the host disk's free space. GDK space information

Verification

On 63bcca43, the same synthetic fixture requests 301 bytes with 300 available and 900 remaining in the quota. The async status and result both return S_OK on main. Both return E_ABORT with the change. Requests of zero bytes or exactly 300 bytes still succeed. The fixture also covers quota-limited and maximum-size requests.

cargo test --locked -p victory-hle --lib modules::storage::tests::prompt_rejects_space_the_host_cannot_supply -- --exact --nocapture

Full HLE library tests with default features and diagnostics, strict HLE Clippy in both configurations, and the repository asset policy passed. The disk capacity is synthetic so the test can run on any host volume.

Coordination claim

AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 11:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/3190) `andrewpozdnakov7-jpg:codex2/pls-available-space` → `main` · +48 −2 · 1 files · 1 commits · open ## Problem The persistent local storage prompt completes immediately. It currently compares the request with the remaining quota, even when the storage query says the host disk can supply fewer bytes. A title can receive `S_OK` and then retry an operation with the same insufficient space. Use the `available_free` value already calculated by the storage query. This accounts for both the remaining quota and the host disk's free space. [GDK space information](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/xpersistentlocalstorage/structs/xpersistentlocalstoragespaceinfo) ## Verification On `63bcca43`, the same synthetic fixture requests **301 bytes** with **300 available** and **900 remaining in the quota**. The async status and result both return `S_OK` on main. Both return `E_ABORT` with the change. Requests of zero bytes or exactly 300 bytes still succeed. The fixture also covers quota-limited and maximum-size requests. ```powershell cargo test --locked -p victory-hle --lib modules::storage::tests::prompt_rejects_space_the_host_cannot_supply -- --exact --nocapture ``` Full HLE library tests with default features and diagnostics, strict HLE Clippy in both configurations, and the repository asset policy passed. The disk capacity is synthetic so the test can run on any host volume. [Coordination claim](https://git.gtahub.st/github/Marvisak--VIctory/issues/1633) AI-assisted with Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:33:22 +00:00
Author
Owner

@⁠AurumCarlos on GitHub · 2026-11-26 12:07 UTC · original · reviewed

Looks good to me. I read it together with space() and xasync::finished:

  • The fix: space() already builds available_free as free.min(disk_free(..)), so the prompt now uses the same "writable now" figure that space_info reports at 0x28. A title that checks the space and then prompts gets a consistent answer. When the disk isn't the limit, available_free == total_free, so nothing changes in that case. On non-Windows hosts disk_free returns u64::MAX, so behaviour there is unchanged too.
  • Split into finish_space_prompt: passing SpaceInfo in is a nice way to test the disk-limited case without needing a full disk. The test drives the same path the vtable entry does (finished → XAsyncGetStatus → prompt_result).
  • Rows: (disk_limited, 301) and (disk_limited, 900) are the ones that flip from S_OK to E_ABORT with this change. The quota_limited rows pass on main as well, since there available_free == total_free. They're fine as guards for the quota limit, but a short comment saying so would make it clear they aren't part of the regression.

One nit: the old doc comment on prompt_for_space explained why it completes immediately ("There is nobody to ask"), and the new one drops that. Maybe keep both parts, e.g.:

/// There is nobody to ask: granted when the title can write that much now
/// (the quota's rest, as far as the host disk allows), else declined.
**@⁠AurumCarlos** on GitHub · 2026-11-26 12:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/3190#pullrequestreview-6073861520) · **reviewed** Looks good to me. I read it together with `space()` and `xasync::finished`: - **The fix**: `space()` already builds `available_free` as `free.min(disk_free(..))`, so the prompt now uses the same "writable now" figure that `space_info` reports at 0x28. A title that checks the space and then prompts gets a consistent answer. When the disk isn't the limit, `available_free == total_free`, so nothing changes in that case. On non-Windows hosts `disk_free` returns `u64::MAX`, so behaviour there is unchanged too. - **Split into `finish_space_prompt`**: passing `SpaceInfo` in is a nice way to test the disk-limited case without needing a full disk. The test drives the same path the vtable entry does (`finished` → `XAsyncGetStatus` → `prompt_result`). - **Rows**: `(disk_limited, 301)` and `(disk_limited, 900)` are the ones that flip from `S_OK` to `E_ABORT` with this change. The `quota_limited` rows pass on `main` as well, since there `available_free == total_free`. They're fine as guards for the quota limit, but a short comment saying so would make it clear they aren't part of the regression. One nit: the old doc comment on `prompt_for_space` explained *why* it completes immediately ("There is nobody to ask"), and the new one drops that. Maybe keep both parts, e.g.: ```rust /// There is nobody to ask: granted when the title can write that much now /// (the quota's rest, as far as the host disk allows), else declined. ```
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-26 12:12 UTC · original

Independent local verification of head 4f06549 on Windows 11, Rust 1.100.0/MSVC:

  • cargo test --locked -p victory-hle --lib -- --exact modules::storage::tests::prompt_rejects_space_the_host_cannot_supply — 1 passed, 0 failed.
  • git diff --check origin/main HEAD — clean.

Used a worktree-local CARGO_TARGET_DIR to avoid stale shared-target binaries. Synthetic SpaceInfo/AsyncBlock inputs only; no game assets or DRM material used. AI-assisted (Hy4 flash).

**@⁠cloph-dsp** on GitHub · 2026-11-26 12:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/3190#issuecomment-7191693823) Independent local verification of head `4f06549` on Windows 11, Rust 1.100.0/MSVC: - `cargo test --locked -p victory-hle --lib -- --exact modules::storage::tests::prompt_rejects_space_the_host_cannot_supply` — 1 passed, 0 failed. - `git diff --check origin/main HEAD` — clean. Used a worktree-local `CARGO_TARGET_DIR` to avoid stale shared-target binaries. Synthetic `SpaceInfo`/`AsyncBlock` inputs only; no game assets or DRM material used. AI-assisted (Hy4 flash).
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3190/head:github-bot/gh-3190'
git switch 'github-bot/gh-3190'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3190'
git switch 'github-bot/gh-3190'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3190'
git switch 'github-bot/gh-3190'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3190'
git switch 'main'
git merge --squash 'github-bot/gh-3190'
git switch 'main'
git merge --ff-only 'github-bot/gh-3190'
git switch 'main'
git merge 'github-bot/gh-3190'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3190
No description provided.