Skip to content

Exporter: validate all input before writing so a failed export never damages an existing file #9

Open

Description

@mahach666

Since the new viewer (#8), HtmlViewerExporter.Save validates indices and geometry references before it opens the target file. Some invalid input is still only detected while the page is being written, after FileMode.Create has truncated an existing file:

  • Non-finite numbers (NaN or infinity in vertices, viewpoints, grid lines, clash distances, costs, texture scale) are rejected by Utf8JsonWriter in the middle of the stream. The previous page is replaced by a partial one, although the CHANGELOG says a failed export leaves an existing file as it was. Example: an OBJ with v NaN 0 0 or v 1e400 0 0.
  • Duplicate ViewerElement.Id: instances map to the first element, but the properties block keeps the last one, so the properties panel can show another element's data.
  • A mesh with GeometryId and non-empty Indices, Normals or UVs is accepted and those arrays are silently ignored (only Vertices is rejected).
  • TextureIndex is not range-checked; the viewer throws when switching to Textures mode.

Expected: all of these are rejected up front with InvalidDataException and a clear message, and Save writes to a temporary file in the same folder and moves it into place only on success.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions