Normalize large alias file IDs#23
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Normalize macOS alias file IDs before writing them into the 32-bit fields used by the alias binary format.
Root Cause
APFS inode/file IDs on GitHub macOS runners can exceed
uint32.create()copiedfs.statSync(...).inodirectly into the alias info object, then wrote the parent ID into the type-1 extra record withBuffer.writeUInt32BE(). The same IDs are also written byencode()into the base parent and target ID fields. When a runner returned an inode such as12888353118, Node raisedERR_OUT_OF_RANGEbefore the alias could be encoded.Fix
Added a small file-ID normalizer that keeps valid UInt32 values unchanged and reduces larger positive integer IDs modulo
2^32, matching the storage width of the alias format.create()uses it for target IDs, parent IDs, and the type-1 parent-ID extra record;encode()uses it for the base parent and target ID fields.Validation
npm cinpm testnpm audit --audit-level=moderatenpm ls --omit=dev --allnpm pack --dry-runnode --check index.js lib/create.js lib/encode.js lib/file-id.js lib/decode.js lib/is-alias.js lib/values.js test/basics.js test/addon.jsBeads:
dmg-rtf