Skip to content

Preserve directory traversal callback after entry transforms - #870

Draft
AlexXuz wants to merge 2 commits into
archiverjs:masterfrom
AlexXuz:fix/directory-transform-callback-20261027
Draft

AlexXuz wants to merge 2 commits into
archiverjs:masterfrom
AlexXuz:fix/directory-transform-callback-20261027

Conversation

@AlexXuz

@AlexXuz AlexXuz commented Oct 27, 2026

Copy link
Copy Markdown

Problem

With a directory containing two files, a data function returning fresh metadata hangs after the first entry:

archive.directory(dir, false, ({ name }) => ({ name: 'renamed/' + name }));
await archive.finalize();

The traversal-resume callback is attached before the transform, so a replacement object drops it.

Change

Attach the internal callback after the transform and false-skip handling, immediately before appending the entry. Add four regression cases: replacement objects, in-place mutation, copied objects, and skipping a match before returning fresh metadata. Tests verify finalized JSON archive names, types, and sizes, with bounded timeouts and cleanup.

Validation

  • npm test: 44 passing on Node.js 24.22.1 / Linux.
  • Focused new tests: 4 passing; before the fix, replacement-object and skip cases time out while the other two pass.
  • Prettier and git diff --check pass.

Not tested locally on Windows or other Node.js versions.

@gameroman

Copy link
Copy Markdown

hi @AlexXuz would you be interested in trying a more maintained fork of this package and contributing the fix there as well?

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