Fix file not close when ReadAll returns error in local chunk manager (#15068)

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
congqixia 2022-01-10 11:53:34 +08:00 committed by GitHub
parent f4b5a6733e
commit 998ebcce4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -82,11 +82,12 @@ func (lcm *LocalChunkManager) Read(key string) ([]byte, error) {
if err != nil {
return nil, err
}
defer file.Close()
content, err := ioutil.ReadAll(file)
if err != nil {
return nil, err
}
return content, file.Close()
return content, nil
}
// ReadAt reads specific position data of local storage if exists.