@cryptotaxi247 / kubo / commits / c6b74207b

config/init: init Version with CheckPeriod #265

Juan Batiz-Benet committed Nov 4, 2014 at 18:58 UTC c6b74207bc35504cfa678d632d9d9c32f4feaf62
2 files changed +12 -5
cmd/ipfs/init.go
+1 -4
@@ -136,10 +136,7 @@ func initCmd(c *commander.Command, inp []string) error {
136 }
137
138 // tracking ipfs version used to generate the init folder and adding update checker default setting.
139 - cfg.Version = config.Version{
140 - Check: "error",
141 - Current: updates.Version,
142 - }
139 + cfg.Version = config.VersionDefaultValue()
140
141 err = config.WriteConfigFile(filename, cfg)
142 if err != nil {
config/version.go
+11 -1
@@ -127,8 +127,18 @@ func RecordUpdateCheck(cfg *Config, filename string) {
127
128 if cfg.Version.CheckPeriod == "" {
129 // CheckPeriod was not initialized for some reason (e.g. config file broken)
130 - cfg.Version.CheckPeriod = strconv.Itoa(int(defaultCheckPeriod))
130 + log.Error("config.Version.CheckPeriod not set. config broken?")
131 }
132
133 WriteConfigFile(filename, cfg)
134 }
135 +
136 +// VersionDefaultValue returns the default version config value (for init).
137 +func VersionDefaultValue() Version {
138 + return Version{
139 + Current: CurrentVersionNumber,
140 + Check: "error",
141 + CheckPeriod: strconv.Itoa(int(defaultCheckPeriod)),
142 + AutoUpdate: AutoUpdateMinor,
143 + }
144 +}