Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1408 from somersf/no-fsync
Browse files Browse the repository at this point in the history
internal/fs: Don't Sync() destination file after copy
  • Loading branch information
sdboyer authored Nov 28, 2017
2 parents 91650f0 + ebef7c1 commit f2d75a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions internal/fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit f2d75a0

Please sign in to comment.