diff --git a/cmd/posix.go b/cmd/posix.go index 4be0d1447..6fe37f8f4 100644 --- a/cmd/posix.go +++ b/cmd/posix.go @@ -1182,8 +1182,10 @@ func (s *posix) CreateFile(volume, path string, fileSize int64, r io.Reader) (er return err } } - defer w.Sync() // Sync before close. - defer w.Close() + defer func() { + w.Sync() // Sync before close. + w.Close() + }() var e error if fileSize > 0 {