close file in ScanVolumeFile()

fix https://github.com/chrislusf/seaweedfs/issues/761
This commit is contained in:
Chris Lu
2018-11-04 00:28:24 -07:00
parent 1fcbed4e90
commit f050b22d6c
3 changed files with 22 additions and 5 deletions

View File

@@ -57,6 +57,13 @@ func (v *Volume) Version() Version {
}
func (v *Volume) Size() int64 {
v.dataFileAccessLock.Lock()
defer v.dataFileAccessLock.Unlock()
if v.dataFile == nil {
return 0
}
stat, e := v.dataFile.Stat()
if e == nil {
return stat.Size()
@@ -69,8 +76,14 @@ func (v *Volume) Size() int64 {
func (v *Volume) Close() {
v.dataFileAccessLock.Lock()
defer v.dataFileAccessLock.Unlock()
v.nm.Close()
_ = v.dataFile.Close()
if v.nm != nil {
v.nm.Close()
v.nm = nil
}
if v.dataFile != nil {
_ = v.dataFile.Close()
v.dataFile = nil
}
}
func (v *Volume) NeedToReplicate() bool {