mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
overlay: skip superfluous metadata sets on commit
Signed-off-by: Burke Libbey <burke.libbey@shopify.com>
This commit is contained in:
parent
4676ff3fd7
commit
bc5503f46b
1 changed files with 9 additions and 0 deletions
|
@ -71,9 +71,12 @@ func copyDir(srcDir, dstDir string, flags CopyFlags) error {
|
|||
return fmt.Errorf("Unable to get raw syscall.Stat_t data for %s", srcPath)
|
||||
}
|
||||
|
||||
isHardlink := false
|
||||
|
||||
switch f.Mode() & os.ModeType {
|
||||
case 0: // Regular file
|
||||
if flags&CopyHardlink != 0 {
|
||||
isHardlink = true
|
||||
if err := os.Link(srcPath, dstPath); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -114,6 +117,12 @@ func copyDir(srcDir, dstDir string, flags CopyFlags) error {
|
|||
return fmt.Errorf("Unknown file type for %s\n", srcPath)
|
||||
}
|
||||
|
||||
// Everything below is copying metadata from src to dst. All this metadata
|
||||
// already shares an inode for hardlinks.
|
||||
if isHardlink {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := os.Lchown(dstPath, int(stat.Uid), int(stat.Gid)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue