diff options
| author | Chris Lu <chris.lu@gmail.com> | 2019-09-09 09:48:08 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2019-09-09 09:48:08 -0700 |
| commit | 0f861d23a29d4ecb0f5a020ea68c211fcdd123c9 (patch) | |
| tree | b99ab5773c2831dc9b81fa5c41db75b52963df33 | |
| parent | 972b974f6ca586cc4027d43ce1e56e92226b5359 (diff) | |
| download | seaweedfs-0f861d23a29d4ecb0f5a020ea68c211fcdd123c9.tar.xz seaweedfs-0f861d23a29d4ecb0f5a020ea68c211fcdd123c9.zip | |
avoid nil needle map
fix https://github.com/chrislusf/seaweedfs/issues/1061
| -rw-r--r-- | weed/storage/volume.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/weed/storage/volume.go b/weed/storage/volume.go index a2e34bd04..9c3f74ca4 100644 --- a/weed/storage/volume.go +++ b/weed/storage/volume.go @@ -89,48 +89,72 @@ func (v *Volume) FileStat() (datSize uint64, idxSize uint64, modTime time.Time) func (v *Volume) ContentSize() uint64 { v.dataFileAccessLock.Lock() defer v.dataFileAccessLock.Unlock() + if v.nm == nil { + return 0 + } return v.nm.ContentSize() } func (v *Volume) DeletedSize() uint64 { v.dataFileAccessLock.Lock() defer v.dataFileAccessLock.Unlock() + if v.nm == nil { + return 0 + } return v.nm.DeletedSize() } func (v *Volume) FileCount() uint64 { v.dataFileAccessLock.Lock() defer v.dataFileAccessLock.Unlock() + if v.nm == nil { + return 0 + } return uint64(v.nm.FileCount()) } func (v *Volume) DeletedCount() uint64 { v.dataFileAccessLock.Lock() defer v.dataFileAccessLock.Unlock() + if v.nm == nil { + return 0 + } return uint64(v.nm.DeletedCount()) } func (v *Volume) MaxFileKey() types.NeedleId { v.dataFileAccessLock.Lock() defer v.dataFileAccessLock.Unlock() + if v.nm == nil { + return 0 + } return v.nm.MaxFileKey() } func (v *Volume) IndexFileSize() uint64 { v.dataFileAccessLock.Lock() defer v.dataFileAccessLock.Unlock() + if v.nm == nil { + return 0 + } return v.nm.IndexFileSize() } func (v *Volume) IndexFileContent() ([]byte, error) { v.dataFileAccessLock.Lock() defer v.dataFileAccessLock.Unlock() + if v.nm == nil { + return nil, nil + } return v.nm.IndexFileContent() } func (v *Volume) IndexFileName() string { v.dataFileAccessLock.Lock() defer v.dataFileAccessLock.Unlock() + if v.nm == nil { + return "" + } return v.nm.IndexFileName() } |
