From c802064975099a00c93b0c57f46b1e3964d33eef Mon Sep 17 00:00:00 2001 From: Josh Soref <2119212+jsoref@users.noreply.github.com> Date: Thu, 27 Jan 2022 11:53:26 -0500 Subject: [PATCH] fix: docker cp of dangling symlink (#943) (#948) Co-authored-by: Josh Soref Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- pkg/container/docker_run.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/container/docker_run.go b/pkg/container/docker_run.go index 2077a8e0..9fb8123e 100644 --- a/pkg/container/docker_run.go +++ b/pkg/container/docker_run.go @@ -627,6 +627,11 @@ func (cr *containerReference) copyDir(dstPath string, srcPath string, useGitIgno return err } + // symlinks don't need to be copied + if fi.Mode()&os.ModeSymlink == os.ModeSymlink { + return nil + } + // open files for taring f, err := os.Open(file) if err != nil { @@ -635,10 +640,6 @@ func (cr *containerReference) copyDir(dstPath string, srcPath string, useGitIgno // copy file data into tar writer if _, err := io.Copy(tw, f); err != nil { - if fi.Mode()&os.ModeSymlink == os.ModeSymlink { - // symlinks don't need to be copied, ignore this error - err = nil - } return err }