Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions integration/dockerfiles/Dockerfile_test_issue_3429
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ubuntu

RUN mkdir /test \
&& ln -s /test /link

# Fails on main@1d2bff5 before #3429: On the second run,
# when extracting from cache, we first delete the /test directory
# and thereafter fail to replace the link with a directory.
# The link is now broken and 'stat' returns an error.
# On build this works as we first delete the link,
# and only thereafter create the directory.
RUN rm -rf /test /link \
&& mkdir /link
1 change: 1 addition & 0 deletions integration/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ func NewDockerFileBuilder() *DockerFileBuilder {
"Dockerfile_test_cache_install": {},
"Dockerfile_test_cache_perm": {},
"Dockerfile_test_cache_copy": {},
"Dockerfile_test_issue_3429": {},
}
d.TestOCICacheDockerfiles = map[string]struct{}{
"Dockerfile_test_cache_oci": {},
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/fs_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ func Volumes() []string {

func MkdirAllWithPermissions(path string, mode os.FileMode, uid, gid int64) error {
// Check if a file already exists on the path, if yes then delete it
info, err := os.Stat(path)
info, err := os.Lstat(path)
if err == nil && !info.IsDir() {
logrus.Tracef("Removing file because it needs to be a directory %s", path)
if err := os.Remove(path); err != nil {
Expand Down