mirror of https://github.com/minio/minio.git
placing defer file.Close() right after opening it (#2306)
This commit is contained in:
parent
8b3cb3a0de
commit
6b5fce826b
7
posix.go
7
posix.go
|
@ -492,6 +492,10 @@ func (s *posix) ReadFile(volume string, path string, offset int64, buf []byte) (
|
|||
}
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Close the file descriptor.
|
||||
defer file.Close()
|
||||
|
||||
st, err := file.Stat()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
|
@ -506,9 +510,6 @@ func (s *posix) ReadFile(volume string, path string, offset int64, buf []byte) (
|
|||
return 0, err
|
||||
}
|
||||
|
||||
// Close the reader.
|
||||
defer file.Close()
|
||||
|
||||
// Read full until buffer.
|
||||
m, err := io.ReadFull(file, buf)
|
||||
|
||||
|
|
Loading…
Reference in New Issue