fix(cache): replace entries while Windows readers retain old files #3660

Merged
Celegans12 merged 1 commit from upstream-pr/3660 into main 2026-10-11 21:44:25 +00:00
Celegans12 commented 2026-10-11 15:01:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-11T15:01:26Z.


What

On Windows, publishing a replacement cache entry fails while a delete-sharing reader retains the old file. WriteFileAtomically now uses the extended POSIX rename operation: existing readers keep the original bytes, while new opens see the replacement.

The temporary rename handle closes before returning. Unsupported-operation errors retain the existing filesystem-rename fallback; other failures remove the temporary file and return false. The cache format and entry contents are unchanged.

The existing disk-cache test now retains old and replacement readers, checks exact contents across replacement and deletion, and verifies temporary-file cleanup. Windows uses native delete-sharing handles; POSIX uses file streams.

Tested

Based on main a11c8f7f. Windows 11/MinGW-w64 GCC 15.2.0, -DBUILD_TESTING=ON; both OS builds, registration and libraries pass. agc_shader_disk_cache fails on main on Windows, then passes 1/1 (0.14 s); Linux passes 1/1 (0.11 s), exercising its unchanged path, not a Linux RED.

  • Windows full: 836 scheduled, 827 passed, 4 failed, 5 expected skips (85.23 s).
  • Linux full: 838 scheduled, 801 passed, 4 failed, 33 skipped (345.18 s); skip checker fails.

Windows failures: guest_kernel_sys, windows_exceptions, agc_driver_emulated_color_compare, guest_filesystem; all match main 1e8fff68, whose core/tests equal a11c8f7f.

Linux agc_driver_depth_compare_copy fails unchanged write-watch admission; agc_driver_emulated_color_compare matches exact main 1e8fff68. agc_driver_image_plane_address_on_line_implicit_lod and guest_kernel_stack_protect have historical 0f863c10 controls only, not exact-a11c8f7f proof. Unexpected agc_write_tracking skip remains. Full suites remain failed.

Not tested: unsupported-filesystem fallback, title behavior.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4819983543 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3660). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-11T15:01:26Z. --- ### What On Windows, publishing a replacement cache entry fails while a delete-sharing reader retains the old file. `WriteFileAtomically` now uses the extended POSIX rename operation: existing readers keep the original bytes, while new opens see the replacement. The temporary rename handle closes before returning. Unsupported-operation errors retain the existing filesystem-rename fallback; other failures remove the temporary file and return false. The cache format and entry contents are unchanged. The existing disk-cache test now retains old and replacement readers, checks exact contents across replacement and deletion, and verifies temporary-file cleanup. Windows uses native delete-sharing handles; POSIX uses file streams. ### Tested Based on `main` a11c8f7f. Windows 11/MinGW-w64 GCC 15.2.0, -DBUILD_TESTING=ON; both OS builds, registration and libraries pass. `agc_shader_disk_cache` fails on main on Windows, then passes 1/1 (0.14 s); Linux passes 1/1 (0.11 s), exercising its unchanged path, not a Linux RED. - Windows full: 836 scheduled, 827 passed, 4 failed, 5 expected skips (85.23 s). - Linux full: 838 scheduled, 801 passed, 4 failed, 33 skipped (345.18 s); skip checker fails. Windows failures: `guest_kernel_sys`, `windows_exceptions`, `agc_driver_emulated_color_compare`, `guest_filesystem`; all match main 1e8fff68, whose core/tests equal a11c8f7f. Linux `agc_driver_depth_compare_copy` fails unchanged write-watch admission; `agc_driver_emulated_color_compare` matches exact main 1e8fff68. `agc_driver_image_plane_address_on_line_implicit_lod` and `guest_kernel_stack_protect` have historical 0f863c10 controls only, not exact-a11c8f7f proof. Unexpected `agc_write_tracking` skip remains. Full suites remain failed. Not tested: unsupported-filesystem fallback, title behavior. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
adriadam10 commented 2026-10-11 21:44:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:44:21Z.


Checked the diff (FILE_RENAME_INFO layout assert, FileRenameInfoEx class 22, replace + POSIX flags, handle closed before return, fallback only on unsupported-operation errors, temp file removed on other failures) and ran build + ctest for libSceAgc/libSceAgcDriver on Linux (404/404, agc_shader_disk_cache passes). The Windows path itself relies on your Windows run; merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6114119700 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3660#issuecomment-6114119700). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T21:44:21Z. --- Checked the diff (`FILE_RENAME_INFO` layout assert, `FileRenameInfoEx` class 22, replace + POSIX flags, handle closed before return, fallback only on unsupported-operation errors, temp file removed on other failures) and ran build + ctest for libSceAgc/libSceAgcDriver on Linux (404/404, `agc_shader_disk_cache` passes). The Windows path itself relies on your Windows run; merging.
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
boykopovar/AnyPS5!3660
No description provided.