Skip to content

fix: preserve existing export documents and assets - #84

Merged
rogerdigital merged 1 commit into
mainfrom
fix/1.0-export-integrity
Sep 16, 2026
Merged

rogerdigital merged 1 commit into
mainfrom
fix/1.0-export-integrity

Conversation

@rogerdigital

Copy link
Copy Markdown
Owner

Summary

Execute T1-T2 of the 1.0.0 release readiness plan: protect all outputs from silent overwrite and reproduce the confirmed attachment-corruption defect with a persistent fixture.

T1 — Persistent fixture and corruption regression

  • New src/test-support/memory-vault.ts: an in-memory vault whose writes persist across runs, with real mock TFile instances, text/binary storage, strict create/modify semantics (rejects duplicate creation, wrong-kind modification, aliases binaries), and a metadata cache limited to the fixture's literal wiki links.
  • New src/export/ExportIntegrity.test.ts end-to-end test using the real runner, collector, rewriter and writer. Before the fix it failed exactly as planned: after two sequential single-note exports with overwrite disabled, exports/assets/img.png contained [2] instead of [1].

T2 — Protect all outputs

  • OutputWriter now takes the overwrite policy in its constructor (default true preserves existing callers). External writes use the exclusive wx flag when overwrite is disabled; vault writes reject an existing destination and only create — modify requires overwrite enabled. Conflicts raise an explicit Output already exists error.
  • copyBinaryFile routes through writeBinary (single policy implementation) and throws Attachment source not found for missing sources instead of silently skipping.
  • ExportRunner relocates a single-file export whenever anything occupies its output root (including an existing empty directory), so earlier exports keep their documents, attachments and links intact.
  • Export reports get conflict-free path allocation against the complete planned output list, and are written by a dedicated create-only writer: reports never overwrite anything, including prior reports, even with overwrite enabled.
  • 10-case regression matrix covering sequential exports, empty/occupied roots, occupied timestamp/suffix candidates, batch leaf sharing, export-report.md name collisions, late-appearing destinations, explicit overwrite, and missing attachments.

Also: eslint.config.mts disables obsidianmd/no-nodejs-modules for test files (tests run under vitest in Node and are never bundled).

Validation

  • npx vitest run src/export/ExportIntegrity.test.ts src/export/OutputWriter.test.ts src/export/ExportRunner.test.ts src/export/ExportPlan.test.ts src/export/LinkRewriter.test.ts — 145/145
  • npm test — 378/378 (baseline 360 + 18 new)
  • npm run lint:obsidian-warnings — exit 0
  • npm run build — exit 0

@rogerdigital
rogerdigital merged commit 207a4d3 into main Sep 16, 2026
1 check passed
@rogerdigital
rogerdigital deleted the fix/1.0-export-integrity branch September 16, 2026 03:26
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.

1 participant