Skip to content

fix: 馃悰 .unlink() should not delete empty directories - #1278

Merged
streamich merged 2 commits into
masterfrom
fix-unlink-dir
Aug 10, 2026
Merged

fix: 馃悰 .unlink() should not delete empty directories#1278
streamich merged 2 commits into
masterfrom
fix-unlink-dir

Conversation

@streamich

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI lite review requested due to automatic review settings August 10, 2026 11:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes unlink behavior in the core filesystem so that attempting to unlink a directory (including an empty one) fails with EPERM instead of deleting the directory, and adds regression tests to cover sync/async/promises variants.

Changes:

  • Update Superblock.unlink to throw an EPERM createError(...) when the target node is a directory.
  • Add unlinkSync test coverage for directory paths (empty/non-empty/root), including verifying error.code/error.path.
  • Add coverage confirming that unlinking a symlink to a directory removes only the symlink, not the directory.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/fs-node/src/tests/volume/unlinkSync.test.ts Adds regression tests asserting directory-unlink behavior is EPERM across APIs and does not delete directories.
packages/fs-core/src/Superblock.ts Prevents unlinking directories by throwing EPERM when link.getNode().isDirectory() is true.

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

@streamich
streamich merged commit 8987c43 into master Aug 10, 2026
12 checks passed
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