From 074967ac9bb399a0c440b6e0afca717e8d610432 Mon Sep 17 00:00:00 2001 From: Juan Bustamante Date: Wed, 13 Sep 2023 15:47:05 -0500 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Natalie Arellano Signed-off-by: Juan Bustamante --- pkg/archive/archive.go | 4 ++-- pkg/buildpack/buildpack.go | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/archive/archive.go b/pkg/archive/archive.go index be47f6576..a58261502 100644 --- a/pkg/archive/archive.go +++ b/pkg/archive/archive.go @@ -225,9 +225,9 @@ func WriteDirToTar(tw TarWriter, srcDir, basePath string, uid, gid int, mode int return err } - if previousPath, ok := hardLinkFiles[inode]; ok { + if processedPath, ok := hardLinkFiles[inode]; ok { header.Typeflag = tar.TypeLink - header.Linkname = previousPath + header.Linkname = processedPath header.Size = 0 } else { hardLinkFiles[inode] = header.Name diff --git a/pkg/buildpack/buildpack.go b/pkg/buildpack/buildpack.go index 1a2b3bc49..e658c53e5 100644 --- a/pkg/buildpack/buildpack.go +++ b/pkg/buildpack/buildpack.go @@ -229,8 +229,7 @@ func toDistTar(tw archive.TarWriter, descriptor Descriptor, blob Blob) error { header.Name = path.Join(baseTarDir, header.Name) if header.Typeflag == tar.TypeLink { - header.Linkname = path.Clean(header.Linkname) - header.Linkname = path.Join(baseTarDir, header.Linkname) + header.Linkname = path.Join(baseTarDir, path.Clean(header.Linkname)) } err = tw.WriteHeader(header) if err != nil {