fix(server.Init) Fix wrong error reporting

We should only report error if the snapshot path is not exist and we cannot create a new one.
pull/820/head
Xiang Li 2014-03-22 13:30:14 -04:00
parent a9c25bd3cc
commit 7a2b6e166e
1 changed files with 2 additions and 1 deletions

View File

@ -474,7 +474,8 @@ func (s *server) Init() error {
}
// Create snapshot directory if it does not exist
if err := os.Mkdir(path.Join(s.path, "snapshot"), 0700); err != nil {
err := os.Mkdir(path.Join(s.path, "snapshot"), 0700)
if err != nil && os.IsNotExist(err) {
s.debugln("raft: Snapshot dir error: ", err)
return fmt.Errorf("raft: Initialization error: %s", err)
}