fix ledis-repair config error

This commit is contained in:
siddontang 2014-07-23 08:01:18 +08:00
parent 7a763da082
commit 80689cb3fd
1 changed files with 7 additions and 4 deletions

View File

@ -3,6 +3,7 @@ package main
import (
"encoding/json"
"flag"
"github.com/siddontang/copier"
"github.com/siddontang/ledisdb/ledis"
"github.com/siddontang/ledisdb/leveldb"
"io/ioutil"
@ -36,11 +37,13 @@ func main() {
return
}
if len(cfg.DataDB.Path) == 0 {
cfg.DataDB.Path = path.Join(cfg.DataDir, "data")
}
dbPath := path.Join(cfg.DataDir, "data")
if err = leveldb.Repair(&cfg.DataDB); err != nil {
dbCfg := new(leveldb.Config)
copier.Copy(dbCfg, &cfg.DB)
dbCfg.Path = dbPath
if err = leveldb.Repair(dbCfg); err != nil {
println("repair error: ", err.Error())
}
}