add error message if detecting raft.db file

pull/6158/head
Cory LaNou 2016-03-30 11:39:57 -05:00
parent a961ff9ebf
commit 6c6fe87a40
1 changed files with 9 additions and 0 deletions

View File

@ -90,6 +90,15 @@ func NewClient(config *Config) *Client {
func (c *Client) Open() error {
c.mu.Lock()
defer c.mu.Unlock()
// Check to see if there is a raft db, if so, error out with a message
// to downgrade, export, and then import the meta data
raftFile := filepath.Join(c.path, "raft.db")
if _, err := os.Stat(raftFile); err == nil {
return fmt.Errorf("detected %s. either downgrade and export your meta data to import before continuing, or delete the file to start fresh", raftFile)
}
// Try to load from disk
if err := c.Load(); err != nil {
return err