bfs:弹出BFile的时候确保没有正在被使用

This commit is contained in:
GoEdgeLab
2024-04-27 20:55:04 +08:00
parent e612ad4082
commit 33c8e4b201
5 changed files with 113 additions and 23 deletions

View File

@@ -15,6 +15,8 @@ type FileReader struct {
fileHeader *FileHeader
pos int64
isClosed bool
}
func NewFileReader(bFile *BlocksFile, fp *os.File, fileHeader *FileHeader) *FileReader {
@@ -74,6 +76,10 @@ func (this *FileReader) Reset(fileHeader *FileHeader) {
}
func (this *FileReader) Close() error {
if this.isClosed {
return nil
}
this.isClosed = true
return this.bFile.CloseFileReader(this)
}