提交 8f236b5a 编写于 作者: L Lion

auto close the handle after buffer loaded

上级 b5ffdc37
......@@ -76,7 +76,13 @@ func LoadHeaderFromFile(dbFile string) (*Header, error) {
return nil, fmt.Errorf("open xdb file `%s`: %w", dbFile, err)
}
return LoadHeader(handle)
header, err := LoadHeader(handle)
if err != nil {
return nil, err
}
_ = handle.Close()
return header, nil
}
// LoadHeaderFromBuff wrap the header info from the content buffer
......@@ -112,7 +118,13 @@ func LoadVectorIndexFromFile(dbFile string) ([]byte, error) {
return nil, fmt.Errorf("open xdb file `%s`: %w", dbFile, err)
}
return LoadVectorIndex(handle)
vIndex, err := LoadVectorIndex(handle)
if err != nil {
return nil, err
}
_ = handle.Close()
return vIndex, nil
}
// LoadContent load the whole xdb content from the specified file handle
......@@ -151,5 +163,11 @@ func LoadContentFromFile(dbFile string) ([]byte, error) {
return nil, fmt.Errorf("open xdb file `%s`: %w", dbFile, err)
}
return LoadContent(handle)
cBuff, err := LoadContent(handle)
if err != nil {
return nil, err
}
_ = handle.Close()
return cBuff, nil
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册