From 79e89e2f1201e556fe99cbba026af31d645a6bb9 Mon Sep 17 00:00:00 2001 From: Andreas Franek Date: Mon, 12 Aug 2024 10:31:15 +0200 Subject: [PATCH] (fix #248) follow directory links in `getNode` 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`. --- lib/filesystem.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/filesystem.js b/lib/filesystem.js index d921c50..90fbf2a 100644 --- a/lib/filesystem.js +++ b/lib/filesystem.js @@ -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 { @@ -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`)