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

Use path.Join to generate cache keys #3227

Merged
merged 1 commit into from
Oct 28, 2022

Conversation

gabriel-samfira
Copy link
Collaborator

Using filepath.Join() breaks convertPathToKey() on Windows. Windows should be able to deal with both forward and backslashes. Using backslashes in paths here, will break the way we generate cache keys. convertPathToKey() currently replaces '/' with 0. Changing every code path to accomodate the Windows specific path separator is a lot more involved than allowing Windows to just handle the forward slash paths.

Signed-off-by: Gabriel Adrian Samfira gsamfira@cloudbasesolutions.com

@@ -941,7 +941,7 @@ func (cc *cacheContext) checksum(ctx context.Context, root *iradix.Node, txn *ir
}

// no FollowSymlinkInScope because invalid paths should not be inserted
fp := filepath.Join(target, filepath.FromSlash(p))
fp := path.Join(target, filepath.FromSlash(p))
Copy link
Member

Choose a reason for hiding this comment

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

Rest of the changes sgtm but this one I don't understand. This is the actual FS path for syscalls and filepath.FromSlash has already created a backslash path.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are correct. I got too eager with replacing filepath.Join(). Reverted this bit.

Using filepath.Join() breaks convertPathToKey() on Windows.
Windows should be able to deal with both forward and backslashes.
Using backslashes in paths here, will break the way we generate
cache keys. convertPathToKey() currently replaces '/' with 0.
Changing every code path to accomodate the Windows specific path
separator is a lot more involved than allowing Windows to just
handle the forward slash paths.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
@tonistiigi tonistiigi merged commit 9940833 into moby:master Oct 28, 2022
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.

None yet

2 participants