whisper/mailserver : recover db file when openfile corrupted

This commit is contained in:
ucwong 2020-04-04 02:47:25 +00:00
parent 3cf7d2e9a6
commit da009b060d

View file

@ -70,6 +70,9 @@ func (s *WMailServer) Init(shh *whisper.Whisper, path string, password string, p
}
s.db, err = leveldb.OpenFile(path, &opt.Options{OpenFilesCacheCapacity: 32})
if _, iscorrupted := err.(*errors.ErrCorrupted); iscorrupted {
db, err = leveldb.RecoverFile(path, nil)
}
if err != nil {
return fmt.Errorf("open DB file: %s", err)
}