Skip to content

Fix(#119): deleteFolder should use fs.rm to remove directories#132

Open
everleepham wants to merge 1 commit intometacall:masterfrom
everleepham:fix
Open

Fix(#119): deleteFolder should use fs.rm to remove directories#132
everleepham wants to merge 1 commit intometacall:masterfrom
everleepham:fix

Conversation

@everleepham
Copy link
Copy Markdown

Summary

Fix the deleteFolder helper in src/controller/package.ts to use fs.rm() with { recursive: true, force: true } instead of fs.unlink(). fs.unlink is a unlink syscall and can only remove files so when it is called on a directory it fails with EISDIR on Linux/macOS or EPERM on Windows, leaving orphaned application directories on disk after failed uploads.

Related issue

Fixes #119

Type of change

  • Bug fix

How to test

  1. Checkout the branch
  2. Run npm ci
  3. Run npm test -> all 16 tests should pass, including 2 new tests in the Fix: deleteFolder should use fs.rm to remove directories

Checklist

  • I have read the contributing guidelines
  • I added tests that prove my fix is effective or that my feature works

Notes for reviewers

  • The callback-style fs.rm(path, { recursive, force }, cb) is available since Node 14.14, this project requires Node ≥18.17, so it's safe.
  • The same fs.rm pattern is already used in src/index.ts and src/controller/repository.ts
  • deleteBlob (line 155) correctly uses fs.unlink since it removes a single file, no need to change.

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.

fix: deleteFolder in packageUpload uses fs.unlink instead of fs.rm

1 participant