Repository navigation
fix(builder): --work set to the checkout's own work folder no longer stops with SameFileError - #2285
Conversation
…stops with SameFileError make_game copies the play profile's work/image/chunks.txt from the checkout into the build's work folder before every lift. With --work the checkout's own work folder, the place the development guide sends everything made from the dump, source and destination are the same file, and shutil.copyfile stopped the build at once with SameFileError. The four files copied just before it were already safe (they are copied only when they differ). copy_writable now leaves a file alone when the destination is the source itself (os.path.samefile: the same path, a hard link or a symbolic link to it). tests/test_copy_writable.py copies a file onto itself and onto a hard link of it. Assisted-by: Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Rebased onto main |
adabf1a to
3d4ce7e
Compare
Joey-Magnus
left a comment
There was a problem hiding this comment.
Looks good. copy_writable is only reached for work/image/chunks.txt (nx2/make_game.py:1698), the four profile files (:1694, already skipped by filecmp.cmp when they're the same file) and the window icon (:1887, a different folder). So returning early when os.path.samefile(src, dst) (:1170-1171) is the whole fix for #2331. Comparing by file identity rather than by path, as #1577 did, also covers a symlinked or hard-linked work/ and differences in case on Windows. The early return happens before the chmod, so a read-only profile file the user owns doesn't have its mode changed either.
The extended tests/test_copy_writable.py fails on main with SameFileError and checks that the bytes survive. os.link there works on the Windows runners' NTFS temp folder, and the Windows shard that runs this test passed.
On the red checks: neither comes from this PR. Python source checks (windows-2022, part 1/2) failed only in tests/test_native_astc_texture_count.py (the fixture's scanf deprecation warning under -Werror), which #2397 has since fixed on main. appimage stopped in its System packages step on network timeouts. A rerun, or a rebase onto current main, should turn both green.
|
Thanks for checking the file-identity cases and the Windows result. This is now merged as |
A build from a clone stops within seconds when
--workis the clone's ownwork/folder, where the development guideputs everything made from the dump and CONTRIBUTING.md has developers put the play profile:
shutil.SameFileError: '<clone>/work/image/chunks.txt' and '<clone>/work/image/chunks.txt' are the same file.Fixes #2331.
What changed
nx2/make_game.pycopy_writable: when the destination already exists and is the source itself(
os.path.samefile: the same path, or a hard or symbolic link to it), nothing is copied. Before every lift make_gamecopies
work/image/chunks.txtfrom the checkout into the build's work folder with this function, and with--workthe checkout's own
work/both are one file. The four profile files copied just before it were already safe: they arecopied only when they differ (
filecmp.cmp).tests/test_copy_writable.py: also copies a file onto itself and onto a hard link of itself, and checks its bytesstay.
An earlier pull request, #1577, carried a guard for the same copy (comparing the two paths) beside an unrelated switch;
its author closed it the same day to finish testing. This one is the guard alone, with a test.
How it was tested
Linux (Arch, Python 3.12.16 and 3.14), no GPU involved:
shutil.SameFileErrorand passes with the change.make_game.py --romfs ... --exefs ... --work <clone>/work, the clone'swork/holding the v2.1.0 play profile (hotlist, link order, PGO profile,
image/chunks.txt), on a real dump, stopped at the lift's start (the lift's commandreplaced by a stop, so nothing was translated or compiled): main stops at
work/image/chunks.txtwithSameFileErrorafter reading the game files; with the change it reaches@@stage liftin 4 s, andchunks.txtisunchanged (same SHA-256 before and after).
python -I -B tests/run_all.pyon main 49f75dc with this change (2026-11-11, load 6 to over 100): 360 passed, 4 failed,10 skipped;
tests/test_copy_writable.pypasses. Three of the failures are this machine's and fail on main as well:tests/test_make_game_cache.py(it fails whereverwork/holds the play profile),tests/test_wayland_libdecor_hint.py(Clang 23) and
tests/test_updater_asset_digest.py(only a .NET 10 SDK here); each has a pull request of its own. Thefourth,
nx2/test_depth_sample_types.py, lost its compiler to a SIGKILL while the load was over 100; run aloneafterwards it passes (13 s).
Not tested
--work E:\Hookshot\Hookshot\work); not run here.--work <clone>/workthrough the lift, the compile and the link: stopped at the lift's start.Assisted-by: Claude Opus 5.5
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com