-
Notifications
You must be signed in to change notification settings - Fork 2.7k
switched to tar-fs from node-tar to unpack tars #2826
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
Conversation
|
@arcanis, could you review this please? |
__tests__/commands/pack.js
Outdated
| .pipe(tarFs.extract(destination, { | ||
| strip: 1, | ||
| dmode: parseInt(555, 8), // all dirs should be readable | ||
| fmode: parseInt(444, 8), // all files should be readable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0o555 and 0o444 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed - you forgot this instance :)
src/fetchers/git-fetcher.js
Outdated
| const untarStream = tar.Extract({path: this.dest}); | ||
| const untarStream = tarFs.extract(this.dest, { | ||
| dmode: parseInt(555, 8), // all dirs should be readable | ||
| fmode: parseInt(444, 8), // all files should be readable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
src/fetchers/tarball-fetcher.js
Outdated
| const untarStream = tarFs.extract(this.dest, { | ||
| strip: 1, | ||
| dmode: parseInt(555, 8), // all dirs should be readable | ||
| fmode: parseInt(444, 8), // all files should be readable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same - shouldn't the unpack routine be splitted into an helper, since it used in a few places?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes we need to strip first folder, sometimes not.
And moving dmode,fbmode into a separate function looks like an overkill
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/util/git.js
Outdated
| parser.on('entry', (header, stream, next) => { | ||
| let string = ''; | ||
| stream.on('data', (buffer) => { | ||
| string += buffer.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iirc, this pattern might break when the buffer contains part of an unicode character but not the others. It might be better to concat the buffers together (possibly by storing them in a list and then concatenating everything at once with Buffer.concat) rather than concatenating strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, smart!
I'll do that
src/util/git.js
Outdated
| const extractor = tar.Extract({path: dest}); | ||
| const extractor = tarFs.extract(dest, { | ||
| dmode: parseInt(555, 8), // all dirs should be readable | ||
| fmode: parseInt(444, 8), // all files should be readable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
src/util/git.js
Outdated
| const extractor = tar.Extract({path: dest}); | ||
| const extractor = tarFs.extract(dest, { | ||
| dmode: parseInt(555, 8), // all dirs should be readable | ||
| fmode: parseInt(444, 8), // all files should be readable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
ping @arcanis, ready for another round |
src/util/git.js
Outdated
| stream.on('end', () => { | ||
| update(string); | ||
| fileContent += decoder.end(); | ||
| update(fileContent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it isn't really used anymore, maybe fileContent should be removed completely, using update(decoded.end()) instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
decoded.end() won't return a full string.
It would just return remaining bytes if there were any.
So I needed to accumulate them in a string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, my bad ! I initially thought the decoder was holding the whole buffer 👍
This reverts commit 157a34a.
|
@bestander it could make sense to also use |
* Fix: make sure all extracted tarballs are r/w enabled **Summary** Fixes: #992. This issue was supposed to be fixed by #2826 but it was not setting directory permissions wide enough. This patch uses the `readable` and `writable` options provided by the `tar-fs` package which essentially sets everything to `0o777`. **Test plan** N/A * fewer perms
* Fix: make sure all extracted tarballs are r/w enabled **Summary** Fixes: yarnpkg#992. This issue was supposed to be fixed by yarnpkg#2826 but it was not setting directory permissions wide enough. This patch uses the `readable` and `writable` options provided by the `tar-fs` package which essentially sets everything to `0o777`. **Test plan** N/A * fewer perms
Summary
A mitigation for #2629
Also fixes #961
Based on a few ad-hoc tests (//gitlab.com/linagora/petals-cockpit.git#075bac4c54fee466568c000c7ffe8025f593e212) tar-fs seems to make less IO thus is more stable and a bit faster.
I noticed that we never tested git repos that support archive.
Did they ever work?
Test data:
Using offline-mirror (no download), on my MBPro 13", clean cache and using
node-tarto unzip files.Concurrency 12 - fails
Concurrency 8 - 18 seconds
Concurrency 4 - 18 seconds
Concurrency 2 - 21 seconds
Using offline-mirror (no download), on my MBPro 13", clean cache and using
tar-fsto unzip files.Concurrency 12 - 15 seconds
Concurrency 8 - 15 seconds
Concurrency 4 - 17 seconds
Concurrency 2 - 18 seconds
Downloading packages from internet, on my MBPro 13", clean cache and using
tar-fsto unzip files.Concurrency 12 - failed once
Concurrency 8 - 21 seconds
Concurrency 4 - 23 seconds
Concurrency 2 - 34 seconds
Test plan
yarn add ssh://[email protected]/bestander/test-repo.gitand made sure that archive was accessed and installed.