浏览代码

Merge pull request #33956 from keloyang/fix-cp-with-hardlink

Fix docker cp dir with hard link
Sebastiaan van Stijn 8 年之前
父节点
当前提交
9789530b46
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      pkg/archive/copy.go

+ 3 - 0
pkg/archive/copy.go

@@ -332,6 +332,9 @@ func RebaseArchiveEntries(srcContent io.Reader, oldBase, newBase string) io.Read
 			}
 
 			hdr.Name = strings.Replace(hdr.Name, oldBase, newBase, 1)
+			if hdr.Typeflag == tar.TypeLink {
+				hdr.Linkname = strings.Replace(hdr.Linkname, oldBase, newBase, 1)
+			}
 
 			if err = rebasedTar.WriteHeader(hdr); err != nil {
 				w.CloseWithError(err)