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

internal/fs: Don't Sync() destination file after copy #1408

Merged
merged 2 commits into from
Nov 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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