fix(setup): a rename blocked by a scanner is tried again, and the message carries Windows' error #1138
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1138
Loading…
Reference in a new issue
No description provided.
Delete branch "TrashPanda/Longshot:fix/setup-rename-retry"
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?
Type: fix · Risk: low · Tested on: Linux, RTX 4070 Ti (game-free checks) · Needs: Windows
Why
On Windows the setup can stop at "Could not set up part 8 of 8 (renaming llvm-mingw-...)" every time, even as administrator: right after tar.exe unpacks hundreds of .exe and .dll files, an antivirus scan or the search indexer still holds one open, and the one rename the setup tries fails. The message did not say why.
Restored from Hookshot 3021, by jarynclouatre, and split out of #286 so it can be reviewed and merged on its own.
How to reproduce
Seen on: Windows 10/11 with an antivirus that scans new files (reported on Hookshot)
Settings and switches: defaults
Steps: run the setup on a fresh folder while the scanner is busy with the unpacked tools
Expected: the tools are moved into place
Actual: "Could not set up part 8 of 8 (renaming ...)", with no Windows error
What changed
The setup tries a rename that Windows refused with access denied (5) or a sharing violation (32) again every 250 ms for up to 20 s, and its message carries Windows' error and names the folder to allow in the scanner.
Commits, each with its original author and message:
d7b4dcebfix(setup): a rename blocked by a scanner is tried again, and the message carries Windows' error (jarynclouatre)The Windows setup unpacks each part with tar.exe and then renames the
folder (llvm-mingw--ucrt-x86_64 to llvm-mingw). Right after
tar.exe writes hundreds of .exe and .dll files, an antivirus scan or the
search indexer can still hold one of them open, and MoveFileW on the
folder then fails with access denied (5) or a sharing violation (32).
The setup tried once and said only "Could not set up part 8 of 8
(renaming llvm-mingw-...)", with no Windows error, which matches https://github.com/NotRexed/Hookshot/pull/3011
(every run, also as administrator).
move_retryin setup.c tries those two errors again every 250 ms forup to 20 s; any other error returns at once, and GetLastError is the
last try's. It is used for the part's rename and for both moves of the
staged install into place in
publish_install(not the backup moves).another program is holding the unpacked files, often an antivirus scan,
and names the folder to allow. "Could not finish installing" carries the
error too.
setup_parts.py) does the same on Windows withreplace_retryat bothos.replacecalls ofinstall(); on othersystems a PermissionError is raised at once as before. Its messages
carry the error text.
test_portable_setup_transaction.pycutsmove_retryout withpublish_installand defines Sleep away, so its denied-move case doesnot wait 20 s.
I cannot say which program holds the folder on the reporter's PC; if the
retry is not enough, the next report will carry the error number.
For https://github.com/NotRexed/Hookshot/pull/3011
tests/test_setup_rename_retry.py(new): cutsmove_retryout ofsetup.c and runs it with its own MoveFileW and Sleep, on Linux with gcc:
free, denied 3 times then free (4 calls, 3 waits), sharing violation
twice then free, path not found (1 call, no wait, error 3 kept), denied
for ever (80 calls, 79 waits, error 5). Fails on main (no
move_retry).tests/test_setup_parts_rename_retry.py(new):replace_retrywithos.replace and time.sleep mocked: two PermissionErrors then free,
FileNotFoundError at once, PermissionError for ever (80 tries), not
Windows at once, and
install()uses it at both places. Fails on main.python -I -B tests/run_all.pyon Linux: 445 passed, 85 skipped, 1failed (
test_bake_portability.py: zstandard is not installed here).test_portable_setup_transaction.pyandtest_setup_runtime_paths.py(CI runs them), and a real setup on a PCwhose scanner holds the folder.
Ported to Longshot: Longshot has no Python setup any more (#171), so setup_parts.py and its test are left out. The tool is
now moved into place by place_tool (Longshot), so move_retry is its whole-folder move, the scanner message is the
tool's, and test_setup_tool_merge.py cuts move_retry out with place_tool.
Restored-from: https://github.com/NotRexed/Hookshot/pull/3021
Measurements
Verdict: nothing to measure: a correctness fix off the frame path, covered by game-free checks.
Flags and settings
None.
Testing
Tested: On Linux (kernel 7.0), RTX 4070 Ti,
main@71b1edd8, this PR @d7b4dceb:tests/test_setup_rename_retry.py,tests/test_setup_tool_merge.pypass.tests/test_portable_setup_transaction.pybuilds with-municodeand needs llvm-mingw: it fails the same onmainhere (no Windows compiler), so it is left to CI. The full suite (tests/run_all.py) has not been run on this branch yet; a comment will follow when it has.Not tested: A real setup on a PC whose scanner holds the folder (I am on Linux). Opened as work in progress until it runs in the game.
Must be tested:
Risks
What could break: the setup's moves of the tools into place on Windows.
Turning it off: revert the commit.
Compatibility: Nothing changes.
Checklist
Everyone
type(scope): description) of the status line's type.main.third_party/untouched (a new folder with aPROVENANCE.mdinstead).python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).When it applies
mainand passing here.WIP: fix(setup): a rename blocked by a scanner is tried again, and the message carries Windows' errorto fix(setup): a rename blocked by a scanner is tried again, and the message carries Windows' error