Skip to content

Release 1.3.0: damaged-file diagnosis, isolated SVF generation, richer logging - #36

Merged
TWiesendanger merged 15 commits into
masterfrom
dev
Jul 20, 2026
Merged

TWiesendanger merged 15 commits into
masterfrom
dev

Conversation

@TWiesendanger

Copy link
Copy Markdown
Owner

Highlights

Damaged files are now diagnosed precisely

Inventor refuses some files with "Error loading segment ... in database". Two very
different problems cause that, and MetaReader now tells them apart.

Stale segment registry (repairable): the RSeSegInfo block-count summary drifted out of
sync with the blocks actually stored. No model data is lost, so SegmentRepair patches the
summaries in place. The write is same-size and atomic, and an untouched .pre-repair.bak
copy is saved next to the file first. In the app this is gated behind a one-time typed
acknowledgement, since it rewrites a proprietary structure.

Destroyed segment data (not repairable): runs of zeroed bytes sit where compressed
payload used to be, the signature of a disk fault or an interrupted copy. SegmentDataCheck
decompresses every segment payload to detect this, names the affected segments and reports
how much still reads. No repair is offered, because none can work: the bytes are physically
gone, the stream cannot be re-synchronized past the damage, and Inventor needs every segment
intact. The UI and CLI say so and point at restoring a backup instead. SegmentRepair.Repair
refuses such files outright, before creating any backup, so a stale summary sitting next to
destroyed data can never be "repaired" into a file that still will not open.

Surfaced as a "Damaged file" badge in the app (with the repair button only for the repairable
class), as invmeta segments / invmeta repair in the CLI, and as a new Damaged Files docs page.

3D generation no longer touches your Inventor session

SVF generation used to attach to a running Inventor session when one was up, which made it
vulnerable to the user's modal dialogs, in-progress edits and add-ins. It now always starts
its own dedicated instance via COM activation and always tears it down: Quit first, then a
hard process-kill fallback for the exact PID it spawned. Only PIDs identified as ours are
killed, so a session you already have open is never affected. InventorOpener deliberately
keeps the old attach-or-launch behavior, since opening a file in your own session is the point.

A side benefit: COM activation runs Inventor.exe /Automation, which starts with no splash
screen and no visible window at all.

Richer logging

Every status-bar message is mirrored to the log, so the log tells the same story the user saw.
Added document load timings and counts, damage findings, generation steps, an environment and
launch-mode line at startup, a guaranteed flush on exit, and real exception detail on a number
of paths that previously failed silently (settings read/write, reference-graph build, document
load failure, SVF cache clearing).

Inventor refuses files whose RSeSegInfo block-count summary disagrees
with the blocks actually stored ("the number of objects found in the
segment does not match the segment summary"). SegmentRepair parses the
M-stream block tables of every RSeStorage tree - the document's own and
each embedded model-state member's - decompressing the zstd/zlib
payloads via the new ZstdSharp.Port dependency, compares them with the
registry, and patches stale summaries in place after saving an
untouched .pre-repair.bak sibling (removed again if the repair fails,
since the target is then untouched).

The compound-file reader gains the matching write support: same-size
in-place stream overwrite for both FAT and mini-stream chains with
corrupt-chain guards that refuse rather than write through wrapped
offsets, and an atomic temp-and-replace Save so an interrupted write
can never truncate the file. The registry entry layout is fingerprinted
before any patch offset is trusted, so unknown format revisions get no
verdict instead of a write at the wrong place.

InventorDocument exposes the verdicts (per-segment block counts,
SegmentIssues, HasRepairableSegmentDamage) from a single scan pass per
document, joined to the B/M stream pairs by storage id.

Verified against the damaged customer corpus: repaired files open clean
in Inventor 2027 and are byte-identical to the hand-verified fix.
'invmeta segments' shows per-segment block counts and flags stale
summaries; the new 'invmeta repair' patches them in place (backup
first) and reports exactly what was patched from the repair's own
result, so the printed list can never disagree with what happened to
the file. Both commands are gated away from STEP files and fail with a
friendly message instead of a stack trace on unreadable or read-only
files.
Damage is manufactured at runtime by bumping a healthy sample's
registry summaries through independent offset math - including the
exact signature seen on every damaged customer file so far
(PmGraphics, PmDC and PmBRep stale at once, off by a few counts) - so
no customer data and no corrupt binary lives in the repo. Covers
detection, the numbered .pre-repair.bak backups, repair restoring
byte-identical pristine files, and healthy files being left untouched.
…e tab

The viewer flags repairable segment damage with a red badge (tooltip
lists each stale summary), walks the user through a one-time typed risk
acknowledgement plus a per-repair confirmation before patching (backup
first), and then swaps to a green "Repaired" chip with an "Open in
Inventor" shortcut that hands the file to a running session - or
launches the preferred release - to verify the fix. Dialog flows are
reentrancy-guarded and fully wrapped, so double-clicks or I/O failures
surface as status messages instead of crashing the app; a repair whose
fresh scan finds nothing reports that honestly instead of pretending.

The File Structure tab replaces the raw text dump with a segment
database card (proportional size bars, block counts, red damage chips)
above a collapsible storage tree that names the segment behind each
mangled M/B stream and folds noisy subtrees like the VBA project. The
classic dump remains available via "Copy as text", prebuilt while the
container is open so the click never touches the disk.

DocumentView.xaml.cs (2,300 lines by now) is split into focused
partials along the way - Repair, Structure, States, Cards, Sidebar,
References - pure member moves, verified lossless. SvfGenerator's COM
plumbing (ConnectOrLaunch, message filter, error mapping) is widened to
internal and shared with the new InventorOpener.
@TWiesendanger TWiesendanger self-assigned this Jul 20, 2026
@TWiesendanger TWiesendanger added bug Something isn't working enhancement New feature or request labels Jul 20, 2026
@TWiesendanger
TWiesendanger merged commit b109a44 into master Jul 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant