mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
94a8c8b3c0
full diff: 3bbb99cdbd...0f039a052c
- tonistiigi/fsutil#66 copy: add fast copy path for darwin
- tonistiigi/fsutil#67 Treat Unix sockets as regular files
- relates to moby/buildkit#1144 Fix socket handling
- tonistiigi/fsutil#68 fix gocrypto commit
- tonistiigi/fsutil#69 receive: use filter on receive diff
- prevents incremental transfers with userns because the metadata
on disk is always different than the one being transferred.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
48 lines
984 B
Go
48 lines
984 B
Go
package fs
|
|
|
|
import (
|
|
"io"
|
|
"os"
|
|
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func (c *copier) copyFileInfo(fi os.FileInfo, name string) error {
|
|
if err := os.Chmod(name, fi.Mode()); err != nil {
|
|
return errors.Wrapf(err, "failed to chmod %s", name)
|
|
}
|
|
|
|
// TODO: copy windows specific metadata
|
|
|
|
return nil
|
|
}
|
|
|
|
func copyFile(source, target string) error {
|
|
src, err := os.Open(source)
|
|
if err != nil {
|
|
return errors.Wrapf(err, "failed to open source %s", source)
|
|
}
|
|
defer src.Close()
|
|
tgt, err := os.Create(target)
|
|
if err != nil {
|
|
return errors.Wrapf(err, "failed to open target %s", target)
|
|
}
|
|
defer tgt.Close()
|
|
|
|
return copyFileContent(tgt, src)
|
|
}
|
|
|
|
func copyFileContent(dst, src *os.File) error {
|
|
buf := bufferPool.Get().(*[]byte)
|
|
_, err := io.CopyBuffer(dst, src, *buf)
|
|
bufferPool.Put(buf)
|
|
return err
|
|
}
|
|
|
|
func copyXAttrs(dst, src string, xeh XAttrErrorHandler) error {
|
|
return nil
|
|
}
|
|
|
|
func copyDevice(dst string, fi os.FileInfo) error {
|
|
return errors.New("device copy not supported")
|
|
}
|