Skip to content

Commit

Permalink
Merge pull request #3227 from gabriel-samfira/fix-contenthash-on-windows
Browse files Browse the repository at this point in the history
Use path.Join to generate cache keys
  • Loading branch information
tonistiigi authored Oct 28, 2022
2 parents 838a9ae + b1d33dd commit 9940833
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cache/contenthash/checksum.go
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ func splitWildcards(p string) (d1, d2 string) {
p2 = append(p2, p)
}
}
return filepath.Join(p1...), filepath.Join(p2...)
return path.Join(p1...), path.Join(p2...)
}

func containsWildcards(name string) bool {
Expand Down Expand Up @@ -1015,7 +1015,7 @@ func (cc *cacheContext) scanPath(ctx context.Context, m *mount, p string) (retEr
Type: CacheRecordTypeSymlink,
Linkname: filepath.ToSlash(link),
}
k := []byte(filepath.Join("/", filepath.ToSlash(p)))
k := []byte(path.Join("/", filepath.ToSlash(p)))
k = convertPathToKey(k)
txn.Insert(k, cr)
return nil
Expand All @@ -1024,15 +1024,15 @@ func (cc *cacheContext) scanPath(ctx context.Context, m *mount, p string) (retEr
return err
}

err = filepath.Walk(parentPath, func(path string, fi os.FileInfo, err error) error {
err = filepath.Walk(parentPath, func(itemPath string, fi os.FileInfo, err error) error {
if err != nil {
return errors.Wrapf(err, "failed to walk %s", path)
return errors.Wrapf(err, "failed to walk %s", itemPath)
}
rel, err := filepath.Rel(mp, path)
rel, err := filepath.Rel(mp, itemPath)
if err != nil {
return err
}
k := []byte(filepath.Join("/", filepath.ToSlash(rel)))
k := []byte(path.Join("/", filepath.ToSlash(rel)))
if string(k) == "/" {
k = []byte{}
}
Expand All @@ -1043,7 +1043,7 @@ func (cc *cacheContext) scanPath(ctx context.Context, m *mount, p string) (retEr
}
if fi.Mode()&os.ModeSymlink != 0 {
cr.Type = CacheRecordTypeSymlink
link, err := os.Readlink(path)
link, err := os.Readlink(itemPath)
if err != nil {
return err
}
Expand Down

0 comments on commit 9940833

Please sign in to comment.