From 608ae51a03ee01b4f2802d30740733e6f8e8db14 Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Tue, 27 Sep 2016 01:46:28 -0700 Subject: [PATCH] Avoiding copying files if they are already present in chrootw --- client/allocdir/alloc_dir_unix.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/allocdir/alloc_dir_unix.go b/client/allocdir/alloc_dir_unix.go index 0807505c4bb0..0c8185dfcb65 100644 --- a/client/allocdir/alloc_dir_unix.go +++ b/client/allocdir/alloc_dir_unix.go @@ -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