소스 검색

applyLayer() use btrfs reflinks if availible

We use the new file copy helper which uses btrfs reflinks if availible.
Alexander Larsson 12 년 전
부모
커밋
062a2b32e9
1개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  1. 6 2
      image.go

+ 6 - 2
image.go

@@ -284,12 +284,16 @@ func (image *Image) applyLayer(layer, target string) error {
 				}
 				dstFile := os.NewFile(uintptr(fd), targetPath)
 				srcFile, err := os.Open(srcPath)
-				_, err = io.Copy(dstFile, srcFile)
 				if err != nil {
+					_ = dstFile.Close()
 					return err
 				}
-				_ = srcFile.Close()
+				err = CopyFile(dstFile, srcFile)
 				_ = dstFile.Close()
+				_ = srcFile.Close()
+				if err != nil {
+					return err
+				}
 			} else {
 				return fmt.Errorf("Unknown type for file %s", srcPath)
 			}