sync before closing file

merge changes from 1747fc2d52
This commit is contained in:
Chris Lu 2020-02-04 10:37:14 -08:00
parent dc786a63ac
commit 3a35632d58

View file

@ -128,8 +128,17 @@ func (m *LevelDbNeedleMap) Delete(key NeedleId, offset Offset) error {
}
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 {