From bdfed16d42cc49b0a3c2e925a1784f12c986c768 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 7 Mar 2021 01:49:06 -0800 Subject: [PATCH] avoid nil exception fix https://github.com/chrislusf/seaweedfs/issues/1869 --- weed/storage/needle_map_leveldb.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/weed/storage/needle_map_leveldb.go b/weed/storage/needle_map_leveldb.go index 9716e9729..31c86d124 100644 --- a/weed/storage/needle_map_leveldb.go +++ b/weed/storage/needle_map_leveldb.go @@ -152,8 +152,10 @@ func (m *LevelDbNeedleMap) Close() { glog.Warningf("close index file %s failed: %v", indexFileName, err) } - if err := m.db.Close(); err != nil { - glog.Warningf("close levelDB failed: %v", err) + if m.db != nil { + if err := m.db.Close(); err != nil { + glog.Warningf("close levelDB failed: %v", err) + } } }