mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:50:52 +01:00
[PR #1648] feature_scan: write --out atomically and keep the existing report on failure #1662
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1662
Loading…
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/ubiquitarianism/leonida/pull/1648
Author: @xel1uz
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/feature-scan-atomic-out📝 Commits (1)
362b854feature_scan: write --out atomically and keep the old report on failure📊 Changes
2 files changed (+84 additions, -2 deletions)
View changed files
📝
tests/test_feature_scan.py(+68 -0)📝
tools/feature_scan.py(+16 -2)📄 Description
Item ID:
FEATURE-SCAN-ATOMIC-OUT(new item; the coordination issue #14 is at GitHub's 2,500-comment cap, so the claim lives here)Claimed as:
FEATURE-SCAN-ATOMIC-OUT- a failed--outwrite truncates an existing report and leaves a partial file. Reproduced on42537e7b.What and why
feature_scanwrote its report withopen(a.out, "w")followed byjson.dump, so the target was truncated the moment the file was opened, before anything had been serialized. A write that then fails (EFBIG, ENOSPC, an interrupt) leaves a partial JSON behind and the previous report gone - the failure path printsERROR: cannot write ...and returns 2, but the damage is already done and invisible to the caller.The write is now atomic: the JSON goes to a
tempfile.mkstempfile in the same directory as the target, is flushed and closed, and is moved into place withos.replace; on any failure the temp file is removed and the existing report is left untouched. The error message, the exit code 2 and themakedirsbehaviour for a missing parent folder are unchanged.Reproduction (synthetic input, 32-byte existing report,
ulimit -f 1forcing a short write):Tested
pytest tests/test_feature_scan.py -qwith the tool at42537e7b: 1 failed, 15 passed - the failure isFeatureScanAtomicOutputTests::test_failed_write_keeps_existing_report(assertEqual(stream.read(), original)).git diff --checkclean;python3 -I scripts/check_no_game_data.py tools/feature_scan.py tests/test_feature_scan.pyclean.GPUs tested: n/a - CPU only, no Vulkan device involved.
AI-assisted: Yes.
Checklist
main(42537e7b) and merges cleanly.docs/design.md- not applicable, no translator change.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.