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

fixes hardlink collitions #3691

Merged
merged 5 commits into from
Jun 26, 2017
Merged

fixes hardlink collitions #3691

merged 5 commits into from
Jun 26, 2017

Conversation

bestander
Copy link
Member

Summary

Fixes #2734

The problem in hardlinking code trying to create a hardlink per package twice.
That might happen when the same there were a few packages hardlinked in a hierarchy.

Test plan

Added test from the issue.

src/util/fs.js Outdated
@@ -450,6 +450,8 @@ async function buildActionsForHardlink(

// push all files to queue
invariant(srcFiles, 'src files not initialised');
// hardlinking is per package, not going into sub packages
srcFiles = srcFiles.filter(f => f !== 'node_modules');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there paths from the node_modules here? Shouldn't they be handled outside of this function (not completely sure how works the linking pipeline yet)? + will it work with bundledDependencies?

@@ -175,13 +176,16 @@ export default class TarballFetcher extends BaseFetcher {
}

async _fetch(): Promise<FetchedOverride> {
const isFilePath = this.reference.startsWith('file:');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copied from #3709 for bundledDependencies case

@bestander
Copy link
Member Author

@arcanis, you were right, this is trickier but I found a way around and added more tests

@bestander
Copy link
Member Author

Review please

@@ -360,6 +360,11 @@ async function buildActionsForHardlink(
const {src, dest} = data;
const onFresh = data.onFresh || noop;
const onDone = data.onDone || noop;
if (files.has(dest)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is all the fix

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if an hardlinked file needs to change? Will it be removed in an earlier pass? Unless it is, maybe we could try comparing the inodes as well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh it does compare inodes for sure, this check just prevents assessing the same path twice, a folder in particular.
We have A -> B structure that we want to hardlink to A1 -> B1, package-linker passes that modules A1 and B1 need to be hardlinked independently but part of hardlinking is that it is recursive, so files in B1 will be scheduled to be linked twice.

I could not find a more elegant way of doing this especially with bundledDependencies because they don't participate in hoisting.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add this comment to the code for clarity

@bestander bestander merged commit 576687b into yarnpkg:master Jun 26, 2017
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.

3 participants