Skip to content

Commit

Permalink
fix: use unix path separator since path already normalized
Browse files Browse the repository at this point in the history
In the case for Windows, this line at
frontend/dockerfile/dockerfile2llb/convert.go#L1142
```go
dest += string(filepath.Separator)
```
was adding the `\\` to a path that is already normalized
to unix-format, hence ending up with dest paths like
`/\\` for `C:\\` and `/test\\` for `C:\\test\\`.

the src paths are well normalized too at ~L1290.

fixes moby#4696

Signed-off-by: Anthony Nandaa <[email protected]>
  • Loading branch information
profnandaa committed Apr 8, 2024
1 parent dc23e43 commit 02c144e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion frontend/dockerfile/dockerfile2llb/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,10 @@ func dispatchCopy(d *dispatchState, cfg copyConfig) error {
}

if cfg.params.DestPath == "." || cfg.params.DestPath == "" || cfg.params.DestPath[len(cfg.params.DestPath)-1] == filepath.Separator {
dest += string(filepath.Separator)
// can use unix path separator since
// at this point, Windows dest path is already normalized
// in `pathRelativeToWorkingDir` above.
dest += "/"
}

var copyOpt []llb.CopyOption
Expand Down
2 changes: 1 addition & 1 deletion solver/llbsolver/file/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func docopy(ctx context.Context, src, dest string, action pb.FileActionCopy, u *
}
destPath, err := cleanPath(action.Dest)
if err != nil {
return errors.Wrap(err, "cleaning path")
return errors.Wrap(err, "cleaning destination path")
}
if !action.CreateDestPath {
p, err := fs.RootPath(dest, filepath.Join("/", action.Dest))
Expand Down

0 comments on commit 02c144e

Please sign in to comment.