Skip to content

fix: make asset deletion idempotent - #2533

Open
ZluxYao wants to merge 1 commit into
jackyzha0:v5from
ZluxYao:fix/idempotent-asset-delete
Open

ZluxYao wants to merge 1 commit into
jackyzha0:v5from
ZluxYao:fix/idempotent-asset-delete

Conversation

@ZluxYao

@ZluxYao ZluxYao commented Aug 25, 2026

Copy link
Copy Markdown

Summary

  • replace unlink with rm(..., { force: true }) for deleted assets
  • prevent incremental rebuilds from failing when the generated asset is already absent
  • add a regression test that deletes the same asset twice

Reproduction

When a delete event is replayed after its generated asset has already been removed, the asset emitter throws ENOENT and aborts the incremental rebuild.

Testing

  • npm run check
  • npm test (164 tests passed)

This PR was written entirely using an LLM.

@github-actions

github-actions Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
quartz ✅ Ready (View Log) Visit Preview 1930712

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new test cleanup should use force: true to avoid afterEach failures if a temp directory is already missing, preventing flaky test behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR makes asset deletion during incremental rebuilds idempotent by switching from fs.promises.unlink to fs.promises.rm(..., { force: true }), preventing ENOENT from aborting rebuilds when a delete event is replayed.

Changes:

  • Replace fs.promises.unlink with fs.promises.rm(..., { force: true }) for deleted generated assets.
  • Add a regression test to ensure deleting the same asset twice does not fail.
File summaries
File Description
quartz/plugins/emitters/assets.ts Makes delete handling resilient to missing files by using rm(..., { force: true }).
quartz/plugins/emitters/assets.test.ts Adds a regression test covering repeated delete events for the same asset.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

const tempDirs: string[] = []

afterEach(async () => {
await Promise.all(tempDirs.splice(0).map((dir) => fs.promises.rm(dir, { recursive: true })))

This branch was successfully deployed

1 active deployment
Branch Preview — 19307120 Deployed Aug 25, 2026 by github-actions[bot]
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.

2 participants