fix(storage): remove obsolete build files about three times faster #396

Merged
HumanBean merged 4 commits from Jiro113/LongshotLauncher:reclaim-fast-delete into main 2026-12-02 19:35:14 +00:00
Member

Removing obsolete launcher files is very slow on Windows: an old extracted RomFS holds about 186,000 files, and the Storage page's cleanup removed them at a few thousand per second at best. This makes the whole cleanup about three times faster on Windows without loosening what it checks.

What

Before removing each reviewed file, Plan::execute_with_progress called direct(path), which reads the metadata of every folder above the file, then opened the file three times (once for its data, which the antivirus scans).

  • On Windows (remove_reviewed in src/storage/reclaim.rs), each file is opened with DELETE | FILE_READ_ATTRIBUTES, without following a link at the last part of the path. That handle checks that it is still the reviewed file (identity, size, time) and that the path it was reached at (GetFinalPathNameByHandleW, as fs::canonicalize asks it during the scan) is the reviewed path, so a link at any level, swapped in before or during the cleanup, stops it. The same handle then deletes the file (FileDispositionInfoEx with POSIX semantics and the read-only attribute ignored, as fs::remove_file does; FileDispositionInfo on file systems without them). For a read-only file in the fallback, it reopens the checked file by handle to clear the attribute, and attempts to restore it if deletion fails. Nothing can change between that check and the removal.
  • file_identity (src/storage.rs) opens files with attribute access only, so the review and the scan that runs again before the removal don't open each file for its data either.
  • Linux keeps the check of every folder above each file (lstat is cheap there), then the same identity, size and time check and remove_file.

Files that another program has open without sharing read access now get an identity and appear in the plan; if that program doesn't allow deletion either, the cleanup stops at that file with "Could not remove ...", as it does for any file it cannot remove.

Nothing changes on screen: the dialog and its progress are the same.

Measurements

Local, Windows 11, debug build, one synthetic extraction of 50,000 small files four folders deep in a temporary folder, cleaned through scan::plan_for (the review) and Plan::execute (Clean up: the scan again, then the removal); three runs each, same machine, nothing else building (benchmark not committed):

main @ c1bc2e0 this PR @ 0e82392
review 3.39 / 2.62 / 4.70 s 2.42 / 2.53 / 2.19 s
Clean up (scan + removal) 23.86 / 28.54 / 35.66 s 9.92 / 8.86 / 8.44 s
of which removal (Clean up minus a separate scan) ~21.0 / 25.9 / 29.9 s ~7.6 / 6.6 / 6.3 s

Not measured on a real extraction, and not on Linux (where the removal path is the same as before apart from the per-file reads).

Tests

  • New: files changed, replaced, gone, or replaced by a file of the same size and time after the review are kept; a folder replaced by a junction (symlink on Linux) after the review, or after the first removal, stops the cleanup and the rest is kept; a read-only generated file is removed; a link put in the reviewed file's place is kept (Linux, or Windows with Developer Mode).
  • Mutations checked on Windows: without the final-path comparison, both junction tests fail; without the identity comparison, the look-alike test fails; without ignoring the read-only attribute, the read-only test fails.
  • cargo fmt --check and cargo clippy --locked --workspace --all-targets -- -D warnings pass on Windows. cargo test on Windows: 271 pass, and the same 12 tests fail on main on this PC (e.g. storage::reclaim::preservation::previous_build_review_removes_only_selected_outputs_after_confirmation), so tests/test_launcher_core.py stops there too. Tooling's test_release.py: 46 pass.
  • Still to test: the Linux branch was not compiled here (CI will); a real cleanup of a large extraction; FAT/exFAT and network drives. On FAT or Windows before 10 1809, the fallback clears the read-only attribute before deleting the file.

πŸ€– Generated with Claude Code

Removing obsolete launcher files is very slow on Windows: an old extracted RomFS holds about 186,000 files, and the Storage page's cleanup removed them at a few thousand per second at best. This makes the whole cleanup about three times faster on Windows without loosening what it checks. ## What Before removing each reviewed file, `Plan::execute_with_progress` called `direct(path)`, which reads the metadata of every folder above the file, then opened the file three times (once for its data, which the antivirus scans). - On Windows (`remove_reviewed` in src/storage/reclaim.rs), each file is opened with `DELETE | FILE_READ_ATTRIBUTES`, without following a link at the last part of the path. That handle checks that it is still the reviewed file (identity, size, time) and that the path it was reached at (`GetFinalPathNameByHandleW`, as `fs::canonicalize` asks it during the scan) is the reviewed path, so a link at any level, swapped in before or during the cleanup, stops it. The same handle then deletes the file (`FileDispositionInfoEx` with POSIX semantics and the read-only attribute ignored, as `fs::remove_file` does; `FileDispositionInfo` on file systems without them). For a read-only file in the fallback, it reopens the checked file by handle to clear the attribute, and attempts to restore it if deletion fails. Nothing can change between that check and the removal. - `file_identity` (src/storage.rs) opens files with attribute access only, so the review and the scan that runs again before the removal don't open each file for its data either. - Linux keeps the check of every folder above each file (`lstat` is cheap there), then the same identity, size and time check and `remove_file`. Files that another program has open without sharing read access now get an identity and appear in the plan; if that program doesn't allow deletion either, the cleanup stops at that file with "Could not remove ...", as it does for any file it cannot remove. Nothing changes on screen: the dialog and its progress are the same. ## Measurements Local, Windows 11, debug build, one synthetic extraction of 50,000 small files four folders deep in a temporary folder, cleaned through `scan::plan_for` (the review) and `Plan::execute` (Clean up: the scan again, then the removal); three runs each, same machine, nothing else building (benchmark not committed): | | main @ c1bc2e0 | this PR @ 0e82392 | |---|---|---| | review | 3.39 / 2.62 / 4.70 s | 2.42 / 2.53 / 2.19 s | | Clean up (scan + removal) | 23.86 / 28.54 / 35.66 s | 9.92 / 8.86 / 8.44 s | | of which removal (Clean up minus a separate scan) | ~21.0 / 25.9 / 29.9 s | ~7.6 / 6.6 / 6.3 s | Not measured on a real extraction, and not on Linux (where the removal path is the same as before apart from the per-file reads). ## Tests - New: files changed, replaced, gone, or replaced by a file of the same size and time after the review are kept; a folder replaced by a junction (symlink on Linux) after the review, or after the first removal, stops the cleanup and the rest is kept; a read-only generated file is removed; a link put in the reviewed file's place is kept (Linux, or Windows with Developer Mode). - Mutations checked on Windows: without the final-path comparison, both junction tests fail; without the identity comparison, the look-alike test fails; without ignoring the read-only attribute, the read-only test fails. - `cargo fmt --check` and `cargo clippy --locked --workspace --all-targets -- -D warnings` pass on Windows. `cargo test` on Windows: 271 pass, and the same 12 tests fail on main on this PC (e.g. `storage::reclaim::preservation::previous_build_review_removes_only_selected_outputs_after_confirmation`), so `tests/test_launcher_core.py` stops there too. Tooling's `test_release.py`: 46 pass. - Still to test: the Linux branch was not compiled here (CI will); a real cleanup of a large extraction; FAT/exFAT and network drives. On FAT or Windows before 10 1809, the fallback clears the read-only attribute before deleting the file. πŸ€– Generated with [Claude Code](https://claude.com/claude-code)
Removing a reviewed file checked every folder above it for a link and opened
it three times, once for its data. An old RomFS extraction holds about 186,000
files, so the cleanup took minutes. Each folder is now checked once, and each
file is opened once without following a link, with attribute access only:
that handle checks it is still the reviewed file and deletes it, which also
closes the gap between the check and the removal. Reading identities no
longer opens files for their data, so the antivirus does not scan each one.

20,000 files in a deep folder on Windows: 8.3 s before, 1.7 s after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(storage): remove read-only files and say what the cleanup guarantees
Some checks failed
PR title / Conventional Commit title (pull_request) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (actionlint, ShellCheck, gitleaks) (pull_request) Has been cancelled
CI / Rust formatting, lint and tests (pull_request) Has been cancelled
CI / Release packages and stable upgrades (pull_request) Has been cancelled
524a1222c0
The handle-based removal set only POSIX semantics, so a generated file marked
read-only stopped the cleanup halfway, where fs::remove_file removed it. It now
ignores the read-only attribute as fs::remove_file does. A folder put in a
file's place reads as a changed file again, the metadata error names the file,
and the comment on folder links says what really bounds the removal: the
identity check, since a link swapped in after a folder's check is followed.

Tests: a read-only file is removed; a file of the same size and time put in the
reviewed place, or a link to the reviewed file, is kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Member

Possibly related, for context:

  • PR #317 feat(versions): show previous launcher builds and remove one in one action β€” Open PR uses the same previous-build cleanup/reclaim path
  • PR #320 perf(storage): speed up cleanup checks and show file progress β€” Merged performance change to the same cleanup/reclaim path
  • issue #336 Idea: Automatically clean up superseded nightly builds and builder cache β€” Open request for cleanup of superseded builds and builder cache
Possibly related, for context: - PR #317 feat(versions): show previous launcher builds and remove one in one action β€” Open PR uses the same previous-build cleanup/reclaim path - PR #320 perf(storage): speed up cleanup checks and show file progress β€” Merged performance change to the same cleanup/reclaim path - issue #336 Idea: Automatically clean up superseded nightly builds and builder cache β€” Open request for cleanup of superseded builds and builder cache
Author
Member
@review
BeanBot left a comment

Recommendation: Request changes. The cached directory check can delete files after their folder has been moved outside the reviewed location. The Windows fallback also cannot remove read-only files on filesystems that reject the extended disposition flags.

The change reduces repeated directory checks and Windows file opens during storage cleanup. It speeds up a synthetic Windows removal benchmark, but weakens the protection against directory changes during cleanup and has an incomplete Windows fallback.

Blocking (1): must change before merging.

  1. L1 src/storage/reclaim.rs:255: A checked directory remains trusted after it is replaced by a link, so file identity no longer confines deletion to the reviewed path. (more on the line) Do: Keep directory handles that prevent or detect replacement while removing their children, or revalidate the path before each removal. Add a test that swaps the folder after the first progress callback.

Should fix (1): not blocking, but worth doing before merging.

  • L2 src/storage/reclaim.rs:326: The legacy disposition fallback does not ignore the read-only attribute. (more on the line) Do: Implement a handle-based fallback that handles read-only files safely, and test the fallback with a read-only file on a filesystem that rejects the extended flags.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L3 src/storage/reclaim.rs:225: The reported benchmark does not show the gain for the full cleanup players run, including its rescan. (more on the line) Do: Measure several complete cleanups of the same large extraction on the base and head, on the same Windows machine and settings, and report both total and removal times.

@fix can do L1 and L2.

Questions (1) (not confirmed from the code; they don't hold the recommendation)

  • Can Linux cleanup and representative FAT/exFAT or network-drive cleanup be exercised before merge?

Checks: Still running: 5 checks.

More: does it help, other systems, switches, what was read

Does it help: Unproven for the claimed real cleanup: the PR reports 8.3 seconds on the base and 1.7 and 1.9 seconds on the head for 20,000 synthetic files in a Windows debug build. The base has one run, and neither a real extraction nor the complete cleanup workflow was measured.

Other systems: The directory-check change affects Windows and Linux. Windows also changes identity opens used by storage measurement and uses new deletion APIs; FAT/exFAT and network drives were not tested. The Linux removal branch was not compiled or run by the author. This does not affect rendering, audio, input, or saves directly.

Switches: None.

Reviewed: 524a1222c0 against c1bc2e0059: Read AGENTS.md, CONTRIBUTING.md, docs/pull-requests.md, the commits, all changed code and tests, and the relevant scan, identity, link-check and removal paths. Skimmed the remaining storage and scan code. No review checklist or pull request template was present.; nothing run (a code review).

Checked and fine:

  • The new fixtures are synthetic and the commits include AI-assistance trailers.
  • The last path component is opened without following a reparse point on Windows, and the tests cover replacement before removal.

Testing: No code or tests were run, as requested. The author reports Windows formatting and Clippy passing, with 270 tests passing and 12 failures also present on the base; CI is still running.

Overlaps and merge order: Not checked; the network is closed.


Automated code review by BeanBot (gpt-6.1-terra), asked for by Jiro113. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The cached directory check can delete files after their folder has been moved outside the reviewed location. The Windows fallback also cannot remove read-only files on filesystems that reject the extended disposition flags. The change reduces repeated directory checks and Windows file opens during storage cleanup. It speeds up a synthetic Windows removal benchmark, but weakens the protection against directory changes during cleanup and has an incomplete Windows fallback. **Blocking (1)**: must change before merging. 1. **L1** `src/storage/reclaim.rs:255`: A checked directory remains trusted after it is replaced by a link, so file identity no longer confines deletion to the reviewed path. (more on the line) **Do:** Keep directory handles that prevent or detect replacement while removing their children, or revalidate the path before each removal. Add a test that swaps the folder after the first progress callback. **Should fix (1)**: not blocking, but worth doing before merging. - **L2** `src/storage/reclaim.rs:326`: The legacy disposition fallback does not ignore the read-only attribute. (more on the line) **Do:** Implement a handle-based fallback that handles read-only files safely, and test the fallback with a read-only file on a filesystem that rejects the extended flags. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L3** `src/storage/reclaim.rs:225`: The reported benchmark does not show the gain for the full cleanup players run, including its rescan. (more on the line) **Do:** Measure several complete cleanups of the same large extraction on the base and head, on the same Windows machine and settings, and report both total and removal times. `@fix` can do L1 and L2. **Questions (1)** (not confirmed from the code; they don't hold the recommendation) - Can Linux cleanup and representative FAT/exFAT or network-drive cleanup be exercised before merge? **Checks:** Still running: 5 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven for the claimed real cleanup: the PR reports 8.3 seconds on the base and 1.7 and 1.9 seconds on the head for 20,000 synthetic files in a Windows debug build. The base has one run, and neither a real extraction nor the complete cleanup workflow was measured. **Other systems:** The directory-check change affects Windows and Linux. Windows also changes identity opens used by storage measurement and uses new deletion APIs; FAT/exFAT and network drives were not tested. The Linux removal branch was not compiled or run by the author. This does not affect rendering, audio, input, or saves directly. **Switches:** None. **Reviewed:** 524a1222c0ad against c1bc2e0059a1: Read AGENTS.md, CONTRIBUTING.md, docs/pull-requests.md, the commits, all changed code and tests, and the relevant scan, identity, link-check and removal paths. Skimmed the remaining storage and scan code. No review checklist or pull request template was present.; nothing run (a code review). **Checked and fine:** - The new fixtures are synthetic and the commits include AI-assistance trailers. - The last path component is opened without following a reparse point on Windows, and the tests cover replacement before removal. **Testing:** No code or tests were run, as requested. The author reports Windows formatting and Clippy passing, with 270 tests passing and 12 failures also present on the base; CI is still running. **Overlaps and merge order:** Not checked; the network is closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by Jiro113. Nothing was run; a maintainer decides.</sub>
@ -238,0 +222,4 @@
files: &BTreeMap<PathBuf, File>,
mut progress: impl FnMut(usize, usize),
) -> Result<()> {
let total = files.len();
Member

L3 (should fix): The reported benchmark does not show the gain for the full cleanup players run, including its rescan.

When: A real extraction can spend a different share of its time rescanning and checking files than the synthetic removal-only benchmark, so its overall speedup may differ substantially.

Do: Measure several complete cleanups of the same large extraction on the base and head, on the same Windows machine and settings, and report both total and removal times.

**L3** (should fix): The reported benchmark does not show the gain for the full cleanup players run, including its rescan. *When:* A real extraction can spend a different share of its time rescanning and checking files than the synthetic removal-only benchmark, so its overall speedup may differ substantially. **Do:** Measure several complete cleanups of the same large extraction on the base and head, on the same Windows machine and settings, and report both total and removal times.
@ -238,0 +252,4 @@
.iter()
.all(|part| fs::symlink_metadata(part).is_ok_and(|m| !super::is_link(&m)))
{
return false;
Member

L1 (blocking): A checked directory remains trusted after it is replaced by a link, so file identity no longer confines deletion to the reviewed path.

When: After cleanup removes the first file in a folder, another program moves that folder elsewhere and puts a junction or symlink at its old path. The cached check accepts the link, and the remaining files still have the reviewed identities, so cleanup deletes them in the moved folder.

Do: Keep directory handles that prevent or detect replacement while removing their children, or revalidate the path before each removal. Add a test that swaps the folder after the first progress callback.

**L1** (blocking): A checked directory remains trusted after it is replaced by a link, so file identity no longer confines deletion to the reviewed path. *When:* After cleanup removes the first file in a folder, another program moves that folder elsewhere and puts a junction or symlink at its old path. The cached check accepts the link, and the remaining files still have the reviewed identities, so cleanup deletes them in the moved folder. **Do:** Keep directory handles that prevent or detect replacement while removing their children, or revalidate the path before each removal. Add a test that swaps the folder after the first progress callback.
@ -238,0 +323,4 @@
size_of_val(&legacy),
) {
return Err(std::io::Error::last_os_error())
.with_context(|| format!("Could not remove {}.", home::display(path)));
Member

L2 (should fix): The legacy disposition fallback does not ignore the read-only attribute.

When: On a filesystem or Windows version that rejects the extended flags, a reviewed read-only file also rejects FileDispositionInfo, so cleanup stops partway through instead of removing it.

Do: Implement a handle-based fallback that handles read-only files safely, and test the fallback with a read-only file on a filesystem that rejects the extended flags.

**L2** (should fix): The legacy disposition fallback does not ignore the read-only attribute. *When:* On a filesystem or Windows version that rejects the extended flags, a reviewed read-only file also rejects FileDispositionInfo, so cleanup stops partway through instead of removing it. **Do:** Implement a handle-based fallback that handles read-only files safely, and test the fallback with a read-only file on a filesystem that rejects the extended flags.
Jiro113 changed title from fix(storage): remove obsolete build files about five times faster to fix(storage): remove obsolete build files about three times faster 2026-12-02 19:10:38 +00:00
fix(storage): keep each removal at the reviewed path
Some checks failed
PR title / Conventional Commit title (pull_request) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (actionlint, ShellCheck, gitleaks) (pull_request) Has been cancelled
CI / Rust formatting, lint and tests (pull_request) Has been cancelled
CI / Release packages and stable upgrades (pull_request) Has been cancelled
0e82392d58
BeanBot's review: once a folder was checked it stayed trusted, so after the
first removal a folder moved away and replaced by a junction led the cleanup to
delete the remaining reviewed files in their new place. On Windows the handle
that deletes a file now gives the path it was reached at, which must be the
reviewed one: a link at any level changes it, and nothing can change between
that check and the removal. The per-folder cache is gone. Linux checks every
folder above each file again, as before this branch: lstat is cheap there.

Test: the folder becomes a junction (symlink on Linux) after the first removal;
the second file is kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member

Pushed 0e82392 for BeanBot's review.

L1 (fixed): right, a folder stayed trusted once checked. The per-folder cache is gone. On Windows the handle that deletes a file now gives the path it was reached at (GetFinalPathNameByHandleW, the call fs::canonicalize makes during the scan), and it must be the reviewed path, so a link at any level stops the cleanup, with no gap between that check and the removal. Linux checks every folder above each file again, as on main. New test removal_stops_when_a_folder_becomes_a_link_during_the_cleanup swaps the folder for a junction (symlink on Linux) after the first progress callback: the second file is kept. It fails without the final-path comparison.

L2 (not changed): the fallback only runs on file systems without POSIX deletion (FAT/exFAT) or Windows before 10 1809. There, fs::remove_file, which main used, can't remove a read-only file either: DeleteFileW fails and its posix_delete retry uses the same extended flags (std sys/fs/windows.rs, unlink). So this isn't a regression, and a fallback that clears the attribute couldn't be tested here (mounting a FAT volume needs an administrator). Noted under Still to test.

L3 (measured): three complete cleanups (review, then Clean up: scan again and removal) of the same synthetic 50,000-file extraction on main and on this PR, same Windows machine: Clean up 23.9–35.7 s on main, 8.4–9.9 s here; removal alone about 21–30 s against 6.3–7.6 s. The description and title now say about three times, not five. A real extraction wasn't measured.

Pushed 0e82392 for BeanBot's review. **L1 (fixed):** right, a folder stayed trusted once checked. The per-folder cache is gone. On Windows the handle that deletes a file now gives the path it was reached at (`GetFinalPathNameByHandleW`, the call `fs::canonicalize` makes during the scan), and it must be the reviewed path, so a link at any level stops the cleanup, with no gap between that check and the removal. Linux checks every folder above each file again, as on main. New test `removal_stops_when_a_folder_becomes_a_link_during_the_cleanup` swaps the folder for a junction (symlink on Linux) after the first progress callback: the second file is kept. It fails without the final-path comparison. **L2 (not changed):** the fallback only runs on file systems without POSIX deletion (FAT/exFAT) or Windows before 10 1809. There, `fs::remove_file`, which main used, can't remove a read-only file either: `DeleteFileW` fails and its `posix_delete` retry uses the same extended flags (std `sys/fs/windows.rs`, `unlink`). So this isn't a regression, and a fallback that clears the attribute couldn't be tested here (mounting a FAT volume needs an administrator). Noted under Still to test. **L3 (measured):** three complete cleanups (review, then Clean up: scan again and removal) of the same synthetic 50,000-file extraction on main and on this PR, same Windows machine: Clean up 23.9–35.7 s on main, 8.4–9.9 s here; removal alone about 21–30 s against 6.3–7.6 s. The description and title now say about three times, not five. A real extraction wasn't measured.
Author
Member
@review
BeanBot left a comment

Recommendation: Approve. The directory check is repeated for each removal, and the reported Windows measurements show a substantial full-cleanup gain. The legacy read-only fallback remains a minor limitation on file systems or Windows versions without extended disposition support. Recommend approval; not approved on the forge.

Cleanup of obsolete build files uses fewer Windows file opens and checks the reviewed file and its resolved path through the deletion handle. This adds platform-specific code but reduces the measured cleanup time while retaining the reviewed-path check.

Should fix (1): not blocking, but worth doing before merging.

  • L2 src/storage/reclaim.rs:326: The legacy disposition fallback does not ignore the read-only attribute. When: On a filesystem or Windows version that rejects the extended flags, a reviewed read-only file also rejects FileDispositionInfo, so cleanup stops partway through instead of removing it. Do: Implement a handle-based fallback that handles read-only files safely, and test the fallback with a read-only file on a filesystem that rejects the extended flags.

@fix can do L2.

Since the last review (on 524a1222c0)
Resolved: L1 (A checked directory remains trusted after it is replaced by a link, so file identity no lo…); L3 (The reported benchmark does not show the gain for the full cleanup players run, including…)
Still open: L2 (The legacy disposition fallback does not ignore the read-only attribute.)

Checks: Still running: 5 checks.

Also noticed (1; not asked for, not blocking)
  • A real large extraction, Linux cleanup, FAT/exFAT and network drives remain untested in the reported runs.
More: does it help, other systems, switches, what was read

Does it help: Yes. On one Windows 11 machine with a synthetic 50,000-file extraction, three full cleanup runs fell from 23.86–35.66 seconds on main to 8.44–9.92 seconds on this PR. A real extraction was not measured.

Other systems: Linux retains a per-file parent check and path-based removal; its changed branch was not compiled in the reported local run. FAT/exFAT and network drives were not tested. The Windows fallback still cannot remove read-only files where extended disposition is unavailable.

Switches: None.

Reviewed: 0e82392d58 against c1bc2e0059: Read AGENTS.md, CONTRIBUTING.md, the full PR diff, the changes since the ledger, reclaim.rs and reclaim/tests.rs. The storage.rs output was truncated and only portions were reviewed. No review checklist or pull request template was found.; nothing run (a code review).

Checked and fine:

  • The new folder-swap test checks that the second file remains after the first removal.
  • The description opens with the problem and reports the measurements and their limits.

Testing: No commands or tests were run. The author reports Windows tests and mutation checks; CI checks were still running.

Overlaps and merge order: Not checked; network access is unavailable.


Automated code review by BeanBot (gpt-6.1-terra), asked for by Jiro113. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The directory check is repeated for each removal, and the reported Windows measurements show a substantial full-cleanup gain. The legacy read-only fallback remains a minor limitation on file systems or Windows versions without extended disposition support. Recommend approval; not approved on the forge. Cleanup of obsolete build files uses fewer Windows file opens and checks the reviewed file and its resolved path through the deletion handle. This adds platform-specific code but reduces the measured cleanup time while retaining the reviewed-path check. **Should fix (1)**: not blocking, but worth doing before merging. - **L2** `src/storage/reclaim.rs:326`: The legacy disposition fallback does not ignore the read-only attribute. *When:* On a filesystem or Windows version that rejects the extended flags, a reviewed read-only file also rejects FileDispositionInfo, so cleanup stops partway through instead of removing it. **Do:** Implement a handle-based fallback that handles read-only files safely, and test the fallback with a read-only file on a filesystem that rejects the extended flags. `@fix` can do L2. **Since the last review** (on 524a1222c0ad) Resolved: L1 (A checked directory remains trusted after it is replaced by a link, so file identity no lo…); L3 (The reported benchmark does not show the gain for the full cleanup players run, including…) Still open: L2 (The legacy disposition fallback does not ignore the read-only attribute.) **Checks:** Still running: 5 checks. <details> <summary>Also noticed (1; not asked for, not blocking)</summary> - A real large extraction, Linux cleanup, FAT/exFAT and network drives remain untested in the reported runs. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes. On one Windows 11 machine with a synthetic 50,000-file extraction, three full cleanup runs fell from 23.86–35.66 seconds on main to 8.44–9.92 seconds on this PR. A real extraction was not measured. **Other systems:** Linux retains a per-file parent check and path-based removal; its changed branch was not compiled in the reported local run. FAT/exFAT and network drives were not tested. The Windows fallback still cannot remove read-only files where extended disposition is unavailable. **Switches:** None. **Reviewed:** 0e82392d58ee against c1bc2e0059a1: Read AGENTS.md, CONTRIBUTING.md, the full PR diff, the changes since the ledger, reclaim.rs and reclaim/tests.rs. The storage.rs output was truncated and only portions were reviewed. No review checklist or pull request template was found.; nothing run (a code review). **Checked and fine:** - The new folder-swap test checks that the second file remains after the first removal. - The description opens with the problem and reports the measurements and their limits. **Testing:** No commands or tests were run. The author reports Windows tests and mutation checks; CI checks were still running. **Overlaps and merge order:** Not checked; network access is unavailable. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by Jiro113. Nothing was run; a maintainer decides.</sub>
Author
Member
@fix
fix(storage): handle read-only files in legacy deletion fallback
Some checks failed
CI / What the change needs (pull_request) Successful in 5s
CI / Lint (actionlint, ShellCheck, gitleaks) (pull_request) Successful in 10s
PR title / Conventional Commit title (pull_request) Successful in 6s
CI / Rust formatting, lint and tests (pull_request) Failing after 50s
CI / Release packages and stable upgrades (pull_request) Failing after 27m28s
43bd13ba8d
As the review on #396 asked.
BeanBot left a comment

Recommendation: Approve. The Windows cleanup is substantially faster in the reported repeated runs, and the fix preserves the fast path while handling read-only files in the legacy fallback. The fallback’s filesystem-specific behavior still needs a run on a suitable volume. Recommend approval; not approved on the forge.

What @fix changed
I changed this pull request: the new head is 43bd13ba8d. I edited its description to match the change.

Changed

  • Legacy read-only deletion fallback: Added handle-based attribute clearing and restoration on deletion failure in src/storage/reclaim.rs:303. Added Windows fallback tests, including an ignored test for a filesystem that rejects extended disposition, in src/storage/reclaim/tests.rs:308. Tests were not run.

Nothing was built or run: the checks run again on the new head.

The launcher removes reviewed obsolete build files faster on Windows while retaining identity and path checks. The legacy fallback adds code to clear the read-only attribute and restore it if deletion fails.

Checks: they run again on this head; a failure shows on the pull request.

Also noticed (5; not asked for, not blocking)
  • A real large extraction, Linux cleanup, FAT/exFAT and network drives remain untested in the reported runs.
  • The PR description still says read-only files stop cleanup on FAT and older Windows, although the new fallback is intended to remove them.
  • The ignored fallback test on a filesystem without extended disposition remains unrun.
  • The new fallback tests have not been run, including the ignored test on a filesystem without extended disposition support.
  • A real large extraction and Linux cleanup have not been measured.
More: does it help, other systems, switches, what was read

Does it help: Yes. The author reports three synthetic Windows cleanups of 50,000 files: 23.86–35.66 seconds on the base and 8.44–9.92 seconds on the PR before the fallback fix. A real extraction was not measured.

Other systems: Linux retains per-file parent checks; its branch was not compiled in the reported local run. FAT/exFAT and network drives have not been tested; the new legacy fallback is Windows-specific.

Switches: LONGSHOT_LEGACY_DELETE_TEST_DIR is added for an ignored Windows test and has no default; it selects a filesystem for that test and does not affect launcher behavior.

Reviewed: 43bd13ba8d against c1bc2e0059: Read the repository rules, the PR diff, the fallback and its tests, and the surrounding cleanup and identity code. Skimmed the larger storage and scan modules and the reported runs; no PR template or review checklist was present.; nothing run (a code review).

Checked and fine:

  • The fallback reopens the checked file by handle before changing its attributes and attempts to restore read-only if legacy deletion fails.
  • The fast Windows disposition path remains in place.
  • The description explains the fallback and its untested filesystem coverage.

Testing: No commands from the project were run. The author reports Windows formatting and Clippy passing, 271 tests passing with 12 failures also present on main, and the Tooling release suite passing; CI has not run on this head.

Overlaps and merge order: Not available from the supplied information.


Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The Windows cleanup is substantially faster in the reported repeated runs, and the fix preserves the fast path while handling read-only files in the legacy fallback. The fallback’s filesystem-specific behavior still needs a run on a suitable volume. Recommend approval; not approved on the forge. **What `@fix` changed** I changed this pull request: the new head is 43bd13ba8db8. I edited its description to match the change. **Changed** - **Legacy read-only deletion fallback**: Added handle-based attribute clearing and restoration on deletion failure in src/storage/reclaim.rs:303. Added Windows fallback tests, including an ignored test for a filesystem that rejects extended disposition, in src/storage/reclaim/tests.rs:308. Tests were not run. Nothing was built or run: the checks run again on the new head. The launcher removes reviewed obsolete build files faster on Windows while retaining identity and path checks. The legacy fallback adds code to clear the read-only attribute and restore it if deletion fails. **Checks:** they run again on this head; a failure shows on the pull request. <details> <summary>Also noticed (5; not asked for, not blocking)</summary> - A real large extraction, Linux cleanup, FAT/exFAT and network drives remain untested in the reported runs. - The PR description still says read-only files stop cleanup on FAT and older Windows, although the new fallback is intended to remove them. - The ignored fallback test on a filesystem without extended disposition remains unrun. - The new fallback tests have not been run, including the ignored test on a filesystem without extended disposition support. - A real large extraction and Linux cleanup have not been measured. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes. The author reports three synthetic Windows cleanups of 50,000 files: 23.86–35.66 seconds on the base and 8.44–9.92 seconds on the PR before the fallback fix. A real extraction was not measured. **Other systems:** Linux retains per-file parent checks; its branch was not compiled in the reported local run. FAT/exFAT and network drives have not been tested; the new legacy fallback is Windows-specific. **Switches:** LONGSHOT_LEGACY_DELETE_TEST_DIR is added for an ignored Windows test and has no default; it selects a filesystem for that test and does not affect launcher behavior. **Reviewed:** 43bd13ba8db8 against c1bc2e0059a1: Read the repository rules, the PR diff, the fallback and its tests, and the surrounding cleanup and identity code. Skimmed the larger storage and scan modules and the reported runs; no PR template or review checklist was present.; nothing run (a code review). **Checked and fine:** - The fallback reopens the checked file by handle before changing its attributes and attempts to restore read-only if legacy deletion fails. - The fast Windows disposition path remains in place. - The description explains the fallback and its untested filesystem coverage. **Testing:** No commands from the project were run. The author reports Windows formatting and Clippy passing, 271 tests passing with 12 failures also present on main, and the Tooling release suite passing; CI has not run on this head. **Overlaps and merge order:** Not available from the supplied information. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.</sub>
HumanBean deleted branch reclaim-fast-delete 2026-12-02 19:35:14 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
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
MagicBeanDev/LongshotLauncher!396
No description provided.