mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#5242
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/4903
Author: @XiaoBinGan
Created: 11/1/2026
Status: 🔄 Open
Base:
main← Head:fix/remove-read-only-windows📝 Commits (1)
6b4fcdaFix #4089: a read-only folder no longer stops a model delete on Windows📊 Changes
2 files changed (+80 additions, -1 deletions)
View changed files
📝
tools/strata_mcp.py(+13 -1)📝
tools/test_strata_mcp.py(+67 -0)📄 Description
Problem and result
Deleting a model on Windows stopped at the first read-only folder and left the rest of the pack on disk (#4089):
Both paths were empty folders with the Windows
ReadOnlyattribute set.tools/strata_mcp.pystrata_remove()deletes a model's plan with
shutil.rmtree(p, onerror=_rmtree_ignore_missing), and the hook only returned forFileNotFoundError, re-raising everything else. Windows refusesRemoveDirectoryon a folder withFILE_ATTRIBUTE_READONLY, even when it is empty, so the first such path became a failure and the delete stoppedthere.
Reproduced on
main(c62d5e3a) on Windows 11, Python 3.11.16: a temporary Strata folder with a read-only emptyfolder and a read-only file inside another folder, deleted through
Tools.strata_remove():(The message text is in Chinese on this machine by its locale; the code is WinError 5,
ERROR_ACCESS_DENIED.)Related discussion
#4089 — the report, with the exact folders and the WinError 5 lines. A focused fix to an existing error hook, not a
new feature, so no separate scope agreement was asked for.
Approach
_rmtree_ignore_missing()still passes a path that is already gone (FileNotFoundError), so a folder abackground scan emptied meanwhile keeps working.
PermissionErrorit now clears the read-only attribute (os.chmod(path, stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC)) and retries exactly that one path with the same functionshutil.rmtreegave it (that is whatpip's
rmtree_errorhandlerdoes for the same Windows rule).funcis the operation that failed, so the retry isthe same operation on the same path, not a deletion of the whole tree.
OSError, and a retry that fails again, still count as a failure exactly as before: this does not hidea locked file (antivirus, a running process).
0o700are the ones the hook needs on any platform; on Windowsos.chmodmaps them to thesingle read-only bit.
Validation
Passed: the new regression test on the branch,
python -m pytest tools/test_strata_mcp.py -q -k RemoveReadOnly(Python 3.11.16, Windows 11): 1 passed, 52 deselected. It builds a read-only empty folder, a read-only file in
another folder, and the model's config, and asserts
strata_remove()reportsfailed: []and that all three aregone.
Passed: the module's full suite on the branch,
python -m pytest tools/test_strata_mcp.py -q: 1 failed, 52passed — the one failure is
MacCatalog::test_deepseek_on_a_mac_offers_the_two_sets_that_were_run_with_the_mac_words,which already fails on unmodified
mainin this checkout (it predates UD-IQ1_S/M being offered on a Mac) and isunrelated to this change.
Failed: the same new test on unmodified
main(only the hook reverted, the test kept):AssertionError: Lists differ: ["rt: [WinError 5] ...", "tokenizer: [WinError 5] ..."] != []attools/test_strata_mcp.py:998. That is the A/B: the test pins the change.Not run: a real model delete from the desktop app on this machine (it needs a multi-GB installed pack), and this
test's run on Linux/macOS (the read-only attribute is a Windows rule; the test skips there).
Limits
PermissionErroris retried. A denial from ACLs or a folder held open by another process still fails, as itshould; the fix is specifically the Windows read-only attribute.
(unlink/rmdir rights come from the parent), so the POSIX branch is untested here.
one as
shutil.rmtreedescends, which is whatfuncgives the hook.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.