Skip to content
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

fix(read): change lstat to stat to correctly evaluate file size #114

Merged
merged 2 commits into from
Jun 2, 2022

Conversation

yorickvP
Copy link
Contributor

@yorickvP yorickvP commented Jun 1, 2022

I'm doing something interesting with cacache, which could be made a lot more efficient if I could symlink files into the cache. This almost works.
However, the content reader uses a couple of lstat calls during integrity checking, which explicitly read details about the symlink and not it's target, returning the wrong sizes.
Changing these calls to stat calls allows my plans to succeed, and shouldn't cause any harm to people not putting symlinks in their cacache.

@yorickvP yorickvP requested a review from a team as a code owner June 1, 2022 08:00
@wraithgar
Copy link
Member

lstat is definitely not what cacache should be using if its intent is to evaluate the size of the file.

Tests are going to have to be fixed.

@wraithgar wraithgar changed the title feat(read): change lstat to stat to support symlinks in the cache fix(read): change lstat to stat to correctly evaluate file size Jun 1, 2022
@yorickvP
Copy link
Contributor Author

yorickvP commented Jun 2, 2022

Updated the commit messages and fixed the tests.

@wraithgar
Copy link
Member

This looks good. Thanks for pointing this out. It was a bug.

Additionally, we were just in the middle of doing some optimizations to pacote to make it stop reading entire things into memory if they're small enough. Your PR brought this case of cacache doing the same to our attention. We can merge this, and we'll now go look into making cacache not try to read 64mb chunks into memory in one go, and stop streaming in 64mb chunks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants