File must be sync'd before closing (#7657)

- group sync and close action into a single defer statement to avoid
  evaluation order related bugs in future.
master
Krishnan Parthasarathi 6 years ago committed by Harshavardhana
parent 55aa20595f
commit c871456269
  1. 6
      cmd/posix.go

@ -1182,8 +1182,10 @@ func (s *posix) CreateFile(volume, path string, fileSize int64, r io.Reader) (er
return err return err
} }
} }
defer w.Sync() // Sync before close. defer func() {
defer w.Close() w.Sync() // Sync before close.
w.Close()
}()
var e error var e error
if fileSize > 0 { if fileSize > 0 {

Loading…
Cancel
Save