Repository navigation
fix: Enable getNode to follow directory links (fixes #248) - #318
Merged
Merged
Conversation
Contributor
Author
|
Follow-up question, why is the getFile (p, followLinks) {
followLinks = typeof followLinks === 'undefined' ? true : followLinksand not getFile (p, followLinks = true) {? |
getNode to follow directory links (fixes #248)getNode to follow directory links (fixes #248)
Member
|
Should probably land after #320 |
Contributor
Author
|
Rebased. |
Contributor
Author
|
Any further input on this? |
erikian
reviewed
Nov 1, 2024
| }); | ||
| it('should stat a symlinked file', async () => { | ||
| const stats = asar.statFile('test/input/stat-symlink.asar', 'real.txt', true); | ||
| return assert.strictEqual(stats.size, 19); |
Member
There was a problem hiding this comment.
Can we assert that this is not a link instead of checking the size? I think it makes the intent clearer:
Suggested change
| return assert.strictEqual(stats.size, 19); | |
| return assert.strictEqual(stats.link, undefined); |
Contributor
Author
There was a problem hiding this comment.
Good point. Done.
This demonstrates issue #248
When called from stat, getNode should follow directory links to ensure that the correct node is returned. Otherwise, node.files[name] will be undefined, causing a TypeError.
erikian
approved these changes
Nov 5, 2024
|
🎉 This PR is included in version 3.2.16 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Fixes #248
As reported in the issue, soft links (or symlinks/symbolic links) can cause a
TypeErrorto occur inasar.stat. This happens when a directory below the stat'ed path is actually a link.This commit adds a test demonstrating the problem and fixes the problem by introducing a
followLinksvariable ingetNodeand resolving directory links, if it is set.This is my first PR in this project so any feedback is welcome. I was not sure whether to implement the fix imperatively or recursively, for example. I.e., it is possible to follow the link like this instead: