applyLayer() use btrfs reflinks if availible

We use the new file copy helper which uses btrfs reflinks if availible.
Upstream-commit: 1a082ed245aaf55cc92e884c988865b195ea0cb7
Component: engine
This commit is contained in:
Alexander Larsson
2013-09-30 17:35:01 -06:00
committed by Tianon Gravi
parent 08576d6eaf
commit 91d411052a
+7 -3
View File
@@ -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
}
err = CopyFile(dstFile, srcFile)
_ = dstFile.Close()
_ = srcFile.Close()
if err != nil {
return err
}
_ = srcFile.Close()
_ = dstFile.Close()
} else {
return fmt.Errorf("Unknown type for file %s", srcPath)
}