Repository navigation
Write non-finite geometry as JSON null and export files atomically - #44
Merged
Merged
Conversation
DwgJsonExporter now checks each geometry value with double.IsFinite: finite values keep the existing six-decimal rounding, non-finite values are written as JSON null and reported through DwgDocument.Diagnostics. WriteFile writes to a temporary file next to the target and moves it into place, so a failed export leaves neither a partial target file nor a temporary file. The CLI prints unexpected failures as a single line instead of a stack trace.
Copy the existing file's DACL (Windows) or mode (Unix) onto the temporary export before writing, and re-apply after the atomic replace, so overwriting a protected JSON file keeps its rights.
Reading or applying the existing DACL (Windows) or mode (Unix) is mandatory when overwriting: propagate failures instead of falling back to directory-inherited rights, so a protected file is never silently replaced. Add a regression test that denies READ_CONTROL and asserts the original is kept with no temp left.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9
Geometry containing NaN or infinity now exports those values as JSON null and records a diagnostic. Finite values retain the existing six-decimal rounding. The CLI reports unexpected errors without a stack trace.
File export writes to a temporary file in the destination directory and atomically moves it into place. When overwriting an existing file, its Windows access rules or Unix mode are applied to the temporary file before writing JSON. Access-right failures abort before replacement. The move is the final operation: access rules are not reapplied afterward, so a copied ACL that denies permission changes cannot turn a successful replacement into an error.
Tests cover non-finite and finite geometry, temporary-file cleanup, failed replacement, exact Windows DACL preservation, overwrite when ACL changes are denied, and abort when the destination ACL cannot be read.
Validation:
Windows ACL behavior was exercised locally. Unix access modes were not exercised locally.