Browse Source

sync before closing file

merge changes from 1747fc2d52
fasthttp
Chris Lu 5 years ago
parent
commit
3a35632d58
  1. 13
      weed/storage/needle_map_leveldb.go

13
weed/storage/needle_map_leveldb.go

@ -128,8 +128,17 @@ func (m *LevelDbNeedleMap) Delete(key NeedleId, offset Offset) error {
} }
func (m *LevelDbNeedleMap) Close() { func (m *LevelDbNeedleMap) Close() {
m.indexFile.Close()
m.db.Close()
indexFileName := m.indexFile.Name()
if err := m.indexFile.Sync(); err != nil {
glog.Warningf("sync file %s failed: %v", indexFileName, err)
}
if err := m.indexFile.Close(); err != nil {
glog.Warningf("close index file %s failed: %v", indexFileName, err)
}
if err := m.db.Close(); err != nil {
glog.Warningf("close levelDB failed: %v", err)
}
} }
func (m *LevelDbNeedleMap) Destroy() error { func (m *LevelDbNeedleMap) Destroy() error {

Loading…
Cancel
Save