Skip to content

Commit

Permalink
config/init: init Version with CheckPeriod #265
Browse files Browse the repository at this point in the history
  • Loading branch information
jbenet committed Nov 5, 2014
1 parent 866c2c8 commit c6b7420
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 1 addition & 4 deletions cmd/ipfs/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,7 @@ func initCmd(c *commander.Command, inp []string) error {
}

// tracking ipfs version used to generate the init folder and adding update checker default setting.
cfg.Version = config.Version{
Check: "error",
Current: updates.Version,
}
cfg.Version = config.VersionDefaultValue()

err = config.WriteConfigFile(filename, cfg)
if err != nil {
Expand Down
12 changes: 11 additions & 1 deletion config/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,18 @@ func RecordUpdateCheck(cfg *Config, filename string) {

if cfg.Version.CheckPeriod == "" {
// CheckPeriod was not initialized for some reason (e.g. config file broken)
cfg.Version.CheckPeriod = strconv.Itoa(int(defaultCheckPeriod))
log.Error("config.Version.CheckPeriod not set. config broken?")
}

WriteConfigFile(filename, cfg)
}

// VersionDefaultValue returns the default version config value (for init).
func VersionDefaultValue() Version {
return Version{
Current: CurrentVersionNumber,
Check: "error",
CheckPeriod: strconv.Itoa(int(defaultCheckPeriod)),
AutoUpdate: AutoUpdateMinor,
}
}

0 comments on commit c6b7420

Please sign in to comment.