Skip to content

awc_manifest: publish mode on Windows (AWC-MANIFEST-STAGE-CLEANUP) - #779

Open
trigger337 wants to merge 3 commits into
ProjectLeonida:mainfrom
trigger337:fix/awc-manifest-stage-cleanup
Open

trigger337 wants to merge 3 commits into
ProjectLeonida:mainfrom
trigger337:fix/awc-manifest-stage-cleanup

Conversation

@trigger337

Copy link
Copy Markdown
Contributor

In tools/awc_manifest.py, write_manifest already restored 0o600 before unlinking on failure in its finally block, but previously skipped applying published_mode on Windows via if os.name != "nt":.

Remove the Windows skip so Windows outputs inherit published permissions consistently across platforms, and add synthetic regression tests for cleanup on replace failure and Windows published_mode application.

Tests pass (25/25 in test_awc_manifest.py), scripts/check_no_game_data.py passes cleanly.

agent: yes
AI-assisted: yes

@tiguan26 tiguan26 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). Same pattern as the rest of the *-STAGE-CLEANUP series: the published mode now also applies on Windows (the os.name guard is gone), using file_mode.published_mode. Only the staging/permission lines change.

AI-assisted (Claude).

@DeadlyChirp

Copy link
Copy Markdown
Contributor

Tested on Windows 11, Python 3.12.10, with this PR merged onto upstream main b0f3d39 (merge commit 1ed165078).

python -I tests/test_awc_manifest.py:

  • PR: 25 tests OK (2 skipped). main: 23 tests OK (2 skipped).
  • The skips are the existing symlink tests (WinError 1314, no symlink privilege). The 2 new tests run and pass.

(AI-assisted test run; output checked by hand.)

@PierreEbele

Copy link
Copy Markdown
Contributor

Reviewed ff7a65d: I ran python3 -I tests/test_awc_manifest.py (25/25 on the PR), test_csv_line_endings.py, test_file_mode.py, test_report_paths.py and check_no_game_data.py (all clean) on Linux, plus a probe against origin/main. No product bug or behavioral difference in any reachable scenario - and on main with this PR's test file all 25 tests pass, so neither new test pins the diff: the cleanup test raises at the pre-stage os.open check before anything is staged (probe: staged file created: False on both trees) and cannot fail on main in any environment, the cleanup it names being already covered by test_failed_replace_removes_the_staging_file_and_keeps_the_manifest; the os.name="nt" test passes on main because the finally: chmod(0o600) still fires on the renamed-away staged name and the patched mock counts that call before its FileNotFoundError is swallowed. Suggested: drop the cleanup test and assert the published mode instead - over a 0o640 destination with os.name="nt", main republishes at 0o600 while this branch preserves 0o640. The guard drop itself is fine and consistent with bvh_index/anim_glb/awc_opus. AI-assisted review.

Recommendation: Fix first

@tiguan26

Copy link
Copy Markdown
Contributor

Confirming @PierreEbele's finding: with this PR's test file against main's tool, every test passes here too (Linux, run as root), so neither new test pins the change. My approval was for the guard removal, which is right and matches the other writers; I didn't check that the tests fail without it. Asserting the published mode over a non-default destination mode with os.name patched to nt, as the review suggests, would pin it. AI-assisted (Claude).

@trigger337
trigger337 force-pushed the fix/awc-manifest-stage-cleanup branch from ff7a65d to ef0fb06 Compare November 28, 2026 17:23
@zmasi

zmasi commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Independent verification on Windows 11 (10.0.26200, x64) of ef0fb06124 merged onto origin/main (e66c65b950, 0 merge conflicts) under both Python 3.12.10 and Python 3.14.5:

  • Green (ef0fb06124 merged onto origin/main):
    • python -I tests/test_awc_manifest.py: Ran 26 tests, OK (skipped=2) on Python 3.12.10 (6.04 s) and Python 3.14.5 (3.18 s; the 2 skips are the existing WinError 1314 symlink privilege checks).
    • python -I tests/test_file_mode.py: Ran 5 tests, OK (skipped=2) on both Python versions.
    • Unmocked NTFS check: writing a new manifest.json publishes 0o666, and attempting to overwrite a 0o444 manifest.json raises PermissionError cleanly with 0 leftover .awc_manifest-*.tmp files.
  • Red-check finding confirmed on native Windows 11 (ef0fb06124 test file against origin/main tools/awc_manifest.py):
    • Running #779's tests/test_awc_manifest.py against unpatched origin/main tools/awc_manifest.py also passes 26/26 (OK (skipped=2)) on both Python 3.12.10 and Python 3.14.5, confirming on native Windows what earlier Linux reviews noted on ff7a65d:
      1. In test_publish_cleans_up_staged_file_when_replace_fails_even_if_readonly, setting os.chmod(path, 0o444) causes os.close(os.open(destination, os.O_WRONLY)) at tools/awc_manifest.py:227 to raise PermissionError before NamedTemporaryFile creates a staging file.
      2. In test_publish_applies_published_mode_on_windows, self.assertTrue(len(chmod_calls) > 0) passes even when if os.name != "nt": skips line 237 because finally: at line 243 calls os.chmod(staged.name, 0o600) after replace_retry renames staged.name (track_chmod appends before real_chmod raises FileNotFoundError). Stubbing published_mode to a distinct mode (e.g. 0o640) and asserting (staged_name, 0o640) was passed before replace_retry would pin the guard removal directly.
  • Hygiene: git diff --check, python -I -m compileall -q, and python -I scripts/check_no_game_data.py all exited 0.

AI-assisted.

@OreoFR

OreoFR commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main 53b77df : red 26 OK (no failure) / green 26 OK.

Red = main + only the test files from this PR (git checkout pr-779 -- tests/test_awc_manifest.py); green = main + the merged PR. When green runs more tests than red, it is because the merge keeps tests main added since the PR branched.

AI-assisted: Claude Code (Claude Opus 5.5).

@trigger337
trigger337 force-pushed the fix/awc-manifest-stage-cleanup branch from ef0fb06 to 7599556 Compare November 29, 2026 15:24
@trigger337

Copy link
Copy Markdown
Contributor Author

@PierreEbele @tiguan26 @OreoFR Updated tests/test_awc_manifest.py so test_publish_applies_published_mode_on_windows asserts that published_mode (0o640) was applied to the staged file rather than checking len(chmod_calls) > 0. Confirmed RED on unpatched main (AssertionError: False is not true : [('/tmp/.../.awc_manifest-...tmp', 384)]) and GREEN (26/26 tests OK) on the PR head. Also merged latest main and registered in #2570 (#2570 (comment)).

AI-assisted: yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants