diff options
| author | Chris Lu <chris.lu@gmail.com> | 2021-03-07 11:03:09 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2021-03-07 11:03:09 -0800 |
| commit | 726edab054208d1f2f8ab83c08687c1871bfb0a9 (patch) | |
| tree | 9457b30d4c213857accf437f71fafa48ef92c05d | |
| parent | bdfed16d42cc49b0a3c2e925a1784f12c986c768 (diff) | |
| download | seaweedfs-726edab054208d1f2f8ab83c08687c1871bfb0a9.tar.xz seaweedfs-726edab054208d1f2f8ab83c08687c1871bfb0a9.zip | |
avoid nil when closing an index
fix https://github.com/chrislusf/seaweedfs/issues/1870
| -rw-r--r-- | weed/storage/needle_map_sorted_file.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/weed/storage/needle_map_sorted_file.go b/weed/storage/needle_map_sorted_file.go index 3449ff9dc..662b90531 100644 --- a/weed/storage/needle_map_sorted_file.go +++ b/weed/storage/needle_map_sorted_file.go @@ -94,8 +94,12 @@ func (m *SortedFileNeedleMap) Delete(key NeedleId, offset Offset) error { } func (m *SortedFileNeedleMap) Close() { - m.indexFile.Close() - m.dbFile.Close() + if m.indexFile != nil { + m.indexFile.Close() + } + if m.dbFile != nil { + m.dbFile.Close() + } } func (m *SortedFileNeedleMap) Destroy() error { |
