asar
asar copied to clipboard
fix: extraction of Mac packed asar files from Windows when the pack contains links
Fixes #50
If an asar is packed on Mac and it contains links across nested directories, the following error will occur when extracting the asar from Windows:
D:\Programming\asar\lib\filesystem.js:141
return node.files[name]
^
TypeError: Cannot read properties of undefined (reading 'files')
at Filesystem.getNode (D:\Programming\asar\lib\filesystem.js:141:19)
at Filesystem.getFile (D:\Programming\asar\lib\filesystem.js:149:23)
at Filesystem.getFile (D:\Programming\asar\lib\filesystem.js:153:19)
at Object.module.exports.extractAll (D:\Programming\asar\lib\asar.js:187:29)
at Command.<anonymous> (D:\Programming\asar\bin\asar.js:72:10)
at Command.listener [as _actionHandler] (D:\Programming\asar\node_modules\commander\index.js:408:31)
at Command._parseCommand (D:\Programming\asar\node_modules\commander\index.js:909:14)
at Command._dispatchSubcommand (D:\Programming\asar\node_modules\commander\index.js:860:18)
at Command._parseCommand (D:\Programming\asar\node_modules\commander\index.js:877:12)
at Command.parse (D:\Programming\asar\node_modules\commander\index.js:712:10)
at ChildProcess.exithandler (child_process.js:308:12)
at maybeClose (internal/child_process.js:998:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
It's caused by the path separator being different between Mac and Windows. getNode
will now detect this case and fix the slashes.
I also added a test for this. extractthis-mac-links.asar
was created on Mac and it contains the link dir2/dir4/file4_link.txt
-> dir1/dir3/file4.txt
. The test would fail when running on Windows without the new logic in getNode
.
The CI pipeline appears to be broken on linux. It's unrelated to this change.