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

Commit f2d75a0

Browse files
authored
Merge pull request #1408 from somersf/no-fsync
internal/fs: Don't Sync() destination file after copy
2 parents 91650f0 + ebef7c1 commit f2d75a0

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ IMPROVEMENTS:
1717

1818
* Log as dependencies are pre-fetched during dep init ([#1176](https://github.com/golang/dep/pull/1176)).
1919
* Make the gps package importable ([#1349](https://github.com/golang/dep/pull/1349)).
20+
* Improve file copy performance by not forcing a file sync (PR #1408).
2021

2122
# v0.3.2
2223

internal/fs/fs.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,7 @@ func CopyDir(src, dst string) error {
407407
// copyFile copies the contents of the file named src to the file named
408408
// by dst. The file will be created if it does not already exist. If the
409409
// destination file exists, all its contents will be replaced by the contents
410-
// of the source file. The file mode will be copied from the source and
411-
// the copied data is synced/flushed to stable storage.
410+
// of the source file. The file mode will be copied from the source.
412411
func copyFile(src, dst string) (err error) {
413412
if sym, err := IsSymlink(src); err != nil {
414413
return errors.Wrap(err, "symlink check failed")
@@ -442,13 +441,14 @@ func copyFile(src, dst string) (err error) {
442441
if err != nil {
443442
return
444443
}
445-
defer out.Close()
446444

447445
if _, err = io.Copy(out, in); err != nil {
446+
out.Close()
448447
return
449448
}
450449

451-
if err = out.Sync(); err != nil {
450+
// Check for write errors on Close
451+
if err = out.Close(); err != nil {
452452
return
453453
}
454454

0 commit comments

Comments
 (0)