Skip to content

Commit

Permalink
Merge pull request #293 from ipfs/fix/validate-state
Browse files Browse the repository at this point in the history
Fix: validateState does not detect different state versions
  • Loading branch information
hsanjuan committed Jan 16, 2018
2 parents b801492 + 5b3be2d commit e596c09
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ipfs-cluster-service/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,16 @@ func validateVersion(cfg *ipfscluster.Config, cCfg *raft.Config) error {
} else if snapExists && err != nil {
logger.Error("error after reading last snapshot. Snapshot potentially corrupt.")
} else if snapExists && err == nil {
raw, err := ioutil.ReadAll(r)
if err != nil {
return err
raw, err2 := ioutil.ReadAll(r)
if err2 != nil {
return err2
}
err = state.Unmarshal(raw)
if err != nil {
err2 = state.Unmarshal(raw)
if err2 != nil {
logger.Error("error unmarshalling snapshot. Snapshot potentially corrupt.")
return err
return err2
}
if state.GetVersion() != state.Version {
if state.GetVersion() != mapstate.Version {
logger.Error("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
logger.Error("Out of date ipfs-cluster state is saved.")
logger.Error("To migrate to the new version, run ipfs-cluster-service state upgrade.")
Expand Down

0 comments on commit e596c09

Please sign in to comment.