-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add entry.isSymlink method [feat] #47
Conversation
Thanks for doing this. Please ping me when you've completed the work and it's ready for review. |
@overlookmotel ready for review |
Again, thanks very much for your work on this. Not had time to review the core implementation yet, but a few things in meantime: Requested changes
|
Method is no longer async.
Renamed method to _mode.
I've commited the fixture to the repo and removed Archiver.
Need some time to come up with zips created by different utilities. Other than WinZip and MacOS Archive Utility do any other come to mind?
Symlinks are files with the path of the target file as their content. For example if these are the file paths:
then symlink_to_file.txt will contain /dir/file.txt |
Just to say, this is the only thing we're waiting for to get this merged:
But I didn't answer your question. Answer is: I guess 7-Zip and WinRAR would be good to add. From googling, they seem to be the most popular programs beyond the ones you already mentioned. Do you have time for that? |
Yup, should be able to add fixtures for 7Zip, WinRaR and MacOS Archive today. Windows handles symlinks in a different way (.lnk file). Will see how to parse that using Node. |
Test for MacOS Archive Utility is failing. Looking into this. To create the zip, I went on a Mac, I created a folder, created a file inside the folder, created an alias for the file and zipped it. Then I sent it over to my pc (linux). $: npm run jest ./test/symlink.test.js
> [email protected] jest
> jest ./test/symlink.test.js
FAIL test/symlink.test.js
Identify symlinks
✓ reads symlink from NodeJS generated zip file (5 ms)
✓ reads symlink from WinZip generated zip file (1 ms)
✓ reads symlink from 7-Zip generated zip file (1 ms)
✓ reads symlink from WinRAR generated zip file (1 ms)
✕ reads symlink from MacOS Archive Utility generated zip file (7 ms)
● Identify symlinks › reads symlink from MacOS Archive Utility generated zip file
expect(received).toEqual(expected) // deep equality
- Expected - 2
+ Received + 2
@@ -15,12 +15,12 @@
"fileName": "__MACOSX/MacOS Archive Utility/._.DS_Store",
"isSymlink": false,
},
Object {
"fileName": "MacOS Archive Utility/file.txt alias",
- "isSymlink": true,
+ "isSymlink": false,
},
Object {
"fileName": "__MACOSX/MacOS Archive Utility/._file.txt alias",
- "isSymlink": true,
+ "isSymlink": false,
},
]
123 | }
124 |
> 125 | expect(zipMetadata).toEqual([
| ^
126 | {fileName: 'MacOS Archive Utility/', isSymlink: false},
127 | {fileName: 'MacOS Archive Utility/file.txt', isSymlink: false},
128 | {fileName: 'MacOS Archive Utility/.DS_Store', isSymlink: false},
at Object.toEqual (test/symlink.test.js:125:23)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 4 passed, 5 total
Snapshots: 0 total
Time: 0.338 s, estimated 1 s
Ran all test suites matching /.\/test\/symlink.test.js/i. |
It would be simpler I think if you removed the That may not be the source of the problem, but it will at least reduce irrelevant noise. |
Turns out the __MACOSX dir is created during/after zipping. The MacOS alias/symlink format created by MacOS Archive Utility is different from the Linux version. Will have to look into this more deeply. Closing this for now, will reopen once I've figured out how to identify those symlinks. |
I'm sorry this is so difficult. Thanks very much for all your efforts. This was exactly the kind of thing I was worried about - that there is not a consistent cross-platform method of representing symlinks in ZIP files, so it's difficult for us to support it. |
Closes: #39
This only identifies if an entry is a symlink. How the symlink is extracted is left up to the developer.