Only check for new version once every 24 hours#151
Conversation
|
|
||
| repo := updaterEnabled | ||
| return update.CheckForUpdate(client, repo, currentVersion) | ||
| stateFilePath, err := homedir.Expand("~/.config/gh/state.yml") |
There was a problem hiding this comment.
I don't like how this file and the config file have knowledge of this directory in separate places, maybe the config directory should be a public method in the config package?
There was a problem hiding this comment.
Good call, this path is already referenced from at least 3 places around the codebase and we might benefit from moving things into a config package to clean it up.
There was a problem hiding this comment.
I started to do this in this PR, but it got a little complicated. So I'm going to open a follow up PR to do this.
| if err != nil { | ||
| return err | ||
| } | ||
| ioutil.WriteFile(stateFilePath, content, 0600) |
There was a problem hiding this comment.
Should we add error handling here?
There was a problem hiding this comment.
This is a good question. Errors from the updater are ignored (line 22 in main.go) so errors aren't going to help us much. We want the updater to be mostly silent, but because of this it will fail silently. I haven't been able to come up with a good solution yet.
|
|
||
| repo := updaterEnabled | ||
| return update.CheckForUpdate(client, repo, currentVersion) | ||
| stateFilePath, err := homedir.Expand("~/.config/gh/state.yml") |
There was a problem hiding this comment.
Good call, this path is already referenced from at least 3 places around the codebase and we might benefit from moving things into a config package to clean it up.
- non-existent file simply returns an error - corrupt file (e.g. YAML unmarshal error) also returns an error - if there were errors, just check for new release normally instead of aborting
|
@probablycorey I'm proceeding with this because 1) code looks great, good job! 2) followup items (such as extracting config logic) can be easily done in separate PRs; and 3) I want to get this in the bugfix release that I will likely cut within the next hour, and I'm assuming you won't be at work yet at that time. 🙇 Ref. #99 |
Wrap errors using "%w" instead of "%v"
Edit scheduler rules with project
This PR makes sure the update notifier doesn't check for new releases too often. It does this by storing the latest version, and the last time we checked for the latest version in
.config/gh/state.ymlCloses #145