diff --git a/CHANGELOG.md b/CHANGELOG.md index c327a9cd6f..810d2381e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ IMPROVEMENTS: * Log as dependencies are pre-fetched during dep init ([#1176](https://github.com/golang/dep/pull/1176)). * Make the gps package importable ([#1349](https://github.com/golang/dep/pull/1349)). +* Improve file copy performance by not forcing a file sync (PR #1408). # v0.3.2 diff --git a/internal/fs/fs.go b/internal/fs/fs.go index bfacfd95af..1ed5d31eb5 100644 --- a/internal/fs/fs.go +++ b/internal/fs/fs.go @@ -407,8 +407,7 @@ func CopyDir(src, dst string) error { // copyFile copies the contents of the file named src to the file named // by dst. The file will be created if it does not already exist. If the // destination file exists, all its contents will be replaced by the contents -// of the source file. The file mode will be copied from the source and -// the copied data is synced/flushed to stable storage. +// of the source file. The file mode will be copied from the source. func copyFile(src, dst string) (err error) { if sym, err := IsSymlink(src); err != nil { return errors.Wrap(err, "symlink check failed") @@ -442,13 +441,14 @@ func copyFile(src, dst string) (err error) { if err != nil { return } - defer out.Close() if _, err = io.Copy(out, in); err != nil { + out.Close() return } - if err = out.Sync(); err != nil { + // Check for write errors on Close + if err = out.Close(); err != nil { return }