Avoiding copying files if they are already present in chrootw (#1753)

This commit is contained in:
Diptanu Choudhury
2016-09-27 11:43:27 -07:00
committed by GitHub
parent ec9e395b27
commit 50e3217211

View File

@@ -28,6 +28,12 @@ var (
)
func (d *AllocDir) linkOrCopy(src, dst string, perm os.FileMode) error {
// Avoid link/copy if the file already exists in the chroot
// TODO 0.6 clean this up. This was needed because chroot creation fails
// when a process restarts.
if fileInfo, _ := os.Stat(dst); fileInfo != nil {
return nil
}
// Attempt to hardlink.
if err := os.Link(src, dst); err == nil {
return nil