Skip to content

Commit

Permalink
(fix #248) follow directory links in getNode
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
AndreasFranek committed Aug 12, 2024
1 parent 17cbb40 commit 79e89e2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/filesystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,13 @@ class Filesystem {
return files
}

getNode (p) {
getNode (p, followLinks) {
followLinks = typeof followLinks === 'undefined' ? true : followLinks
const node = this.searchNodeFromDirectory(path.dirname(p))
const name = path.basename(p)
if (node.link && followLinks) {
return this.getNode(path.join(node.link, name))
}
if (name) {
return node.files[name]
} else {
Expand All @@ -143,7 +147,7 @@ class Filesystem {

getFile (p, followLinks) {
followLinks = typeof followLinks === 'undefined' ? true : followLinks
const info = this.getNode(p)
const info = this.getNode(p, followLinks)

if (!info) {
throw new Error(`"${p}" was not found in this archive`)
Expand Down

0 comments on commit 79e89e2

Please sign in to comment.