cmd/stindex: Add index checking mode ("idxck") (#5262)

This commit is contained in:
Jakob Borg
2018-10-11 21:48:39 +02:00
committed by Audrius Butkevicius
parent 0690fe7585
commit 7b0c49a1b6
3 changed files with 260 additions and 4 deletions

View File

@@ -43,7 +43,19 @@ func Open(location string) (*Lowlevel, error) {
OpenFilesCacheCapacity: dbMaxOpenFiles,
WriteBuffer: dbWriteBuffer,
}
return open(location, opts)
}
// OpenRO attempts to open the database at the given location, read only.
func OpenRO(location string) (*Lowlevel, error) {
opts := &opt.Options{
OpenFilesCacheCapacity: dbMaxOpenFiles,
ReadOnly: true,
}
return open(location, opts)
}
func open(location string, opts *opt.Options) (*Lowlevel, error) {
db, err := leveldb.OpenFile(location, opts)
if leveldbIsCorrupted(err) {
db, err = leveldb.RecoverFile(location, opts)