WIP: fix(fs): DeleteDirectoryRecursively says when the folder is still there #2154
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2154
Loading…
Reference in a new issue
No description provided.
Delete branch "dazemc/Longshot:fix/fs-delete-dir-result"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
nn::fs::DeleteDirectoryRecursivelycallsdelete_tree(path)and returns 0 whatever happened.delete_treedropped every result fromDeleteFileA, its recursion and the finalRemoveDirectoryA, so:save:/is unchanged, and the slot lists again;fs::ResultPathNotFound(0x202), the idiomDeleteFilethree lines away already uses.What changed (
host/nn_fs.c, rebased over #607 so its save path is untouched):delete_treereturnsintand stops at the first entry that will not go, removing the folder only when everything under it went; the HLE now answersR_PATH_NOT_FOUNDfor a vanished path andR_PERMISSION_DENIED(0x320002,fs::ResultPermissionDenied) when the folder outlived the attempt. #607's save branch —save_busy,save_remember_deleted,save_remove,save_changed— is byte-identical; only the in-place (non-save) tail carries the change.This fixes the result codes only — it does not fix the 1023-byte case. A folder at the path buffer's edge whose child path does not fit still builds a
subthat names the folder itself and recurses without end; that is pre-existing onmainand outside what a result code can do. The guard for it, with the find pattern's own buffer (HOS_FS_PATTERN), is #2180, which carries this change; merge this for the result codes, and #2180 alongside or after it for the long-path half. This PR does not close the long-path issue, and its checklist does not claim it.Testing
Tested: new
tests/test_fs_delete_dir.pycompiles the mount table,host_path,delete_tree,fs_delete_directory_recursivelyand the HLE over the posix layer, with a stubbedDeleteFileAthat refuses one file as Windows does:Windows host:
host/nn_fs.cat074a38f5compiles as an x86-64 COFF object with llvm-mingw 20261104's clang 23.1.5 (--target=x86_64-w64-mingw32 -fms-extensions -D_CRT_SECURE_NO_WARNINGS -march=native -ffp-contract=off -O2 -g0 -mcx16 -DA64_POLLING -DA64_WRITE_TRACK, headers fromhost/,third_party/a64-kit/rtand the base's generatedgen/); the full Windows game is not linked on this PC. The five checks that readnn_fs.cand fail here (test_fs_save_commit,test_host_guest_writes,test_damaged_rom_files,test_close_waits_for_save,test_guest_copies) fail identically on untouched1885234b(0 passed, 5 failed) — pre-existing test drift from #607, not this branch. That comparison no longer holds against currentmain:#2171changedtests/test_host_guest_writes.py, one of the five, so the drift is fixed there and this head is simply behind it (the rebase below).run_all --stricton the whole tree: main 813/116/18, branch 814/116/18, failing names identical, the extra pass being the new check.In the game: Arch Linux, Hyprland, RTX 4070 Ti (NVIDIA 620.70.06), a pack over
1885234b, from this branch at2d01cab6: Kokiri Forest (child), 20 s after warm-up — 1811 frames, 90.6 fps, median 11.07 ms, 0 cold frames (base: 1820 frames, 91.0 fps, 11.02 ms). That run does not cover the head.2d01cab6's base is1101b612, which predates #607 (a1c09a3c), and the head074a38f5carries #607's save path:git diff 2d01cab6 074a38f5 -- host/nn_fs.cis 952 insertions / 58 deletions, i.e. #607's whole change to the file, so the save-delete path whose result codes this PR changes was not in the smoked build. Head smoke at074a38f5(pack overa2dc5385, gpu mode alone,HOS_FS_TRACE=1; runspr2154-head-smoke,pr2154-save2andpr2154-erase2-probe): the game boots to its title,Continueopens its Load screen, the repository save loads and plays Kokiri Forest (child), and the game quits cleanly — the head build runs and its save path works. The pause menu's System → Save, with Save focused (not Cancel), writes a real manual save:slot_02appeared at 01:56:20 withprogress.savandcaption.savand the log'sfs: save: published 2 files, and the Load screen lists it untagged at 1:56 a.m. above the twoAutosaverows (1:43 and 1/1 12:00). The manual slot's detail panel offersLoadandCancelonly — no Erase, and the autosave rows are the same; X, Y, ZR, ZL, − and the arrows on the Load screen change nothing, and the title's Options has no erase. The log has nofs: delete treeline, andslot_02'sprogress.savandcaption.savare still there afterwards. The game's erase is not a control the control bridge can press on this PC, so no in-game recursive delete ran; the changed non-savedelete_treetail is host-only, does not run in the game here, and is covered bytests/test_fs_delete_dir.py.Still to test:
\\?\long paths — this PC can only stubDeleteFileA(by hand).slot_02, 1:56 a.m.) offersLoad/Cancelonly — no Erase — so the changed non-savedelete_tree/result-code tail has no in-game run. It is covered bytests/test_fs_delete_dir.py; a person with the game's own erase, or a route that does one, would settle it by hand.Measurements
Nothing to measure: the change adds result codes to a delete path, not a frame path; the in-game run above is a boot/play check and its one-run difference is not attributable.
Risks
A delete that used to report success while failing now reports a failure the game can show; a caller that ignores the result behaves as before but no longer silently loses the delete. #607's save semantics are preserved verbatim (checked with
git diff a1c09a3c HEAD -- host/nn_fs.c: only the define,delete_tree's return and the non-save tail). The one thing a result code cannot reach stays as it is onmain: a folder at the 1023-byte edge whose child path does not fit still recurses without end, and that is #2180's guard, not this change's. No switch; a revert is enough.Checklist
Ready for review
main; the title is a Conventional Commit.074a38f5(title, Load screen, load and play, clean quit), and a manual save is real (slot_02, 01:56:20,fs: save: published 2 files), but no in-game recursive delete could be made: the Load screen's detail for that manual slot offersLoad/Cancelonly — no Erase reachable with the control bridge. The changed non-savedelete_treetail is covered by the game-free test only. Ticks when an in-game delete runs.mise run testpasses (any failure that also fails onmainis named). Rebased ontoa2dc5385;tests/run_all.py --strict --jobs 3insidesystemd-run --user --scope -p MemoryMax=8G -p MemorySwapMax=0with the pinned headers.mainat9e10f6f7was 911/22/18; ata2dc5385it is 911 passed / 23 failed / 18 skipped in 635 s — the 23rd istests/test_sim_turf_pools.py; this head074a38f5: 912 / 23 / 18 in 617 s. Failing names identical (23, compared name by name):nx2/test_import_windows.py,tests/test_close_waits_for_save.py,tests/test_compile_zero_byte.py,tests/test_cpm_discovery.py,tests/test_damaged_rom_files.py,tests/test_dev_packs.py,tests/test_draw_stream_visibility.py,tests/test_fs_save_commit.py,tests/test_fsr_uniform_ownership.py,tests/test_guest_copies.py,tests/test_hold_toggle.py,tests/test_lower_atomg_cas.py,tests/test_menu_i18n.py,tests/test_menu_keys.py,tests/test_menu_slider_ends.py,tests/test_mise_build.py,tests/test_pads_after_menu.py,tests/test_recording_admission.py,tests/test_sim_turf_pools.py,tests/test_sim_turf_settings.py,tests/test_switch_table.py,tests/test_tls_objects.py,tests/test_vibration_menu.py. The 23rd,tests/test_sim_turf_pools.py, is new ona2dc5385since9e10f6f7and is #2174's stale check (it asserts the old zero turf floor, while #2174 made the floor the game's size); it fails identically here. The extra pass is the newtests/test_fs_delete_dir.py(0.1 s). The four checks that readhost/nn_fs.cand still fail onmain(test_fs_save_commit,test_damaged_rom_files,test_close_waits_for_save,test_guest_copies) fail identically here;test_host_guest_writespasses on both after #2171.main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.host/nn_fs.cCOFF object above (llvm-mingw 20261104); the full Windows link is not made here. Linux: the pack overa2dc5385at074a38f5compileshost/nn_fs.cand links.Ready to merge
@Beanstalkrequest was posted on 2026-11-22 00:02, BeanBot answered that only a member ofBigBeanscan start it, and no approval has come yet. The by-hand item has not run either. Ticks when that result is in Tested.pr status: Reviews: none); the Beanstalk approval is waiting for a BigBean.main, measured again or a comment says why the numbers still hold. On head074a38f5after the rebase: the description check passed, 11 checks still running, every build and test jobBlocked by required conditions. The suite re-run and the re-confirmed in-game evidence are in the comment and box above; re-confirm CI when it reports.Tested in game: Kokiri Forest (child), pack over
1885234b, 20 s: 90.6 fps median 11.07 ms, 0 cold frames; boots and plays. Arch Linux/Hyprland, RTX 4070 Ti, NVIDIA 620.70.06. Windows failure path is by hand.342f665d9f992432afbcRebased onto
344deb6c(head992432af); host/nn_fs.c is untouched by the commits since, so the run and the suite diff hold.@Beanstalk Windows: on this branch, delete a save slot with a file held open, and again with a read-only file in the folder — each should return a failure result instead of silent success, and the folder should still be there afterwards. A missing path should give
0x202(ResultPathNotFound).Ready otherwise.
@dazemc only members of
BigBeanscan start the farm.One of them can approve this request by reacting 👍 to it or to this comment.This request was for992432a, and the PR has changed since (074a38f), so a 👍 no longer approves it. Comment@Beanstalkagain to ask for the new commit.fix(fs): DeleteDirectoryRecursively says when the folder is still thereto WIP: fix(fs): DeleteDirectoryRecursively says when the folder is still thereBack to WIP for one box: this head's merge base is
344deb6c, andmainhas since moved toa2dc5385with #2171 (9e10f6f7) fixing the game-free checks (~199 test files,tests/test_host_guest_writes.pyamong them — one of the five this description names as failing identically). The suite numbers here were measured against the oldmain(813/116/18 there, now 911/22/18), so 'mise run test' is unticked until a rebase ontoa2dc5385and a re-run oftests/run_all.py --strict, the five checks that readhost/nn_fs.cincluded.The in-game smoke stands: its record (
2d01cab6, 1811 frames, 90.6 fps, 0 cold frames) matches, andhost/nn_fs.c's changed lines are identical to the head's.The Ready to merge boxes stay unticked, each with its reason beside it: the Windows failure path (held file, read-only,
\\?\paths) is with the Test Farm, waiting for a BigBean; no review yet; CI's build/test jobs are still pending.992432afbc074a38f536Rebased onto
a2dc5385: head is now074a38f5. The rebase was clean — one commit replayed with no conflicts.Full game-free suite, run in the same shape as a clean
a2dc5385baseline (tests/run_all.py --strict --jobs 3,systemd-run --user --scope -p MemoryMax=8G -p MemorySwapMax=0, the pinned headers):a2dc5385: 911 passed / 23 failed / 18 skipped in 635 s074a38f5: 912 / 23 / 18 in 617 sFailing names identical, compared name by name (23); the extra pass is the new
tests/test_fs_delete_dir.py. The one name new ona2dc5385since9e10f6f7istests/test_sim_turf_pools.py: #2174 changed the simulated-turf floor while that old check still asserts a zero floor, so it is stale onmainand red identically here. The four checks that readhost/nn_fs.cand still fail onmain(test_fs_save_commit,test_damaged_rom_files,test_close_waits_for_save,test_guest_copies) fail identically here;test_host_guest_writespasses on both after #2171.In-game evidence (Jev: 0.65, likely valid): the smoked
2d01cab6record matches, the changed lines inhost/nn_fs.care identical to this head, and no commit in344deb6c..a2dc5385touches it. No new in-game run was made.For fspath: this PR's head is now
074a38f5, sofix/fs-pattern-buffershould rebase onto that before it opens.WIP: fix(fs): DeleteDirectoryRecursively says when the folder is still thereto fix(fs): DeleteDirectoryRecursively says when the folder is still there@Beanstalk Windows: on this branch, delete a save slot with a file held open, and again with a read-only file in the folder — each should return a failure result instead of silent success, and the folder should still be there afterwards. A missing path should give
0x202(ResultPathNotFound).Head:
074a38f5(rebased ontoa2dc5385).@dazemc only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.fix(fs): DeleteDirectoryRecursively says when the folder is still thereto WIP: fix(fs): DeleteDirectoryRecursively says when the folder is still thereThe in-game claim was wrong and is corrected: the smoked
2d01cab6sits on1101b612, which predates #607, andgit diff 2d01cab6 074a38f5 -- host/nn_fs.cis 952 insertions / 58 deletions — #607's whole change to the file — so the run does not cover the head's save-delete path. Back to WIP with the game box unticked. A head smoke at074a38f5is queued after the current queue: a game run that deletes a save slot through the game's file-select Erase and checks the slot's folder. Re-ready when it lands.dazemc referenced this pull request2026-11-22 09:24:44 +00:00
Head smoke at
074a38f5(pack overa2dc5385, gpu mode alone,HOS_FS_TRACE=1) is in, and it does not reach the game's Erase, so the in-game box stays unticked and the PR stays WIP.What ran: title →
Continue→ Load screen; New Game → pause → System → Save into a manual slotslot_01; the game loads and plays Kokiri Forest (child) and quits cleanly (runruns/pr2154-head-smoke, shots01-newgame-play/02-save-picker/03-saved).What it could not do: erase. With a real
slot_01present (runs/pr2154-erase-probe, shots00-load.png— both slots listed — and01-detail.png/02-detail-down.png), the Load screen's detail for the manual slot shows Load/Cancel only; the Save screen has Save/Cancel; the title's Options has no erase; X, Y, ZR, ZL, − and the arrows on the Load screen change nothing. Final slot state:slot_00/progress.sav,caption.sav(17:47) andslot_01/progress.sav,caption.sav(01:43) all still present; the log has 0fs: delete treelines, only threefs: save: published …lines. (The earlier04-title-screen/07-detail-downshots are gameplay: that title sequence silently failed, and I am not counting them.)The changed non-save
delete_treetail is host-only, does not run in this game, and is covered bytests/test_fs_delete_dir.pyonly — that is now in Still to test and in the box's reason. Host-build row added and ticked: Windowshost/nn_fs.cCOFF object (llvm-mingw 20261104, clang 23.1.5, 281 symbols;runs/pr2154-win/nn_fs.obj) and the Linux pack overa2dc5385at074a38f5.Not ready: the in-game box needs an actual in-game recursive delete, which needs the game's own erase (not on the rendered screen) or a route that does one.
Correction to the smoke wording above, from the confirmed pause-menu and Save screens: there is no manual slot. The pause menu's System → Save opens one entry (the current play) with Save/Cancel, and choosing it writes a second autosave (
slot_01, 01:43). The Load screen then listsslot_01andslot_00, both tagged Autosave, each withLoad/Cancelonly — no Erase. So the only reachable slots are autosaves and Erase is unavailable; the in-game box stays unticked for that exact reason, and the PR stays WIP. The changed non-savedelete_treetail remains covered bytests/test_fs_delete_dir.pyonly.The save was real this time and the answer is now conclusive. With Save focused (not Cancel — my earlier press was on Cancel and cancelled), the pause menu's System → Save wrote a genuine manual save:
slot_02at 01:56:20,progress.sav+caption.sav, logfs: save: published 2 files. The Load screen lists it untagged at 1:56 a.m. above the twoAutosaverows (1:43, 1/1 12:00) — shotsruns/pr2154-erase2-probe/shots/00-load.png, and its detail01-detail.png:Load/Cancelonly, no Erase (02-detail-down.pngthe same).slot_02is still on disk after the probe; the log has nofs: delete tree.So the game has no erase control on the rendered screen even for a manual save, and the control bridge cannot press one; the in-game box stays unticked for that exact reason and the PR stays WIP. The changed non-save
delete_treetail is covered bytests/test_fs_delete_dir.pyonly. A person with the game's own erase, or a route that does one, would settle it by hand.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.