mirror of
https://github.com/writefreely/writefreely
synced 2024-12-01 04:49:09 +00:00
Add logging around automated update checks
Logs requests when --debug enabled, and always logs errors from the check. Ref T572
This commit is contained in:
parent
37b7755c08
commit
987c74c93a
1 changed files with 8 additions and 0 deletions
|
@ -11,6 +11,7 @@
|
||||||
package writefreely
|
package writefreely
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/writeas/web-core/log"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -37,11 +38,15 @@ type updatesCache struct {
|
||||||
// the cache last checked time. If the version postdates the current 'latest'
|
// the cache last checked time. If the version postdates the current 'latest'
|
||||||
// the version value is replaced.
|
// the version value is replaced.
|
||||||
func (uc *updatesCache) CheckNow() error {
|
func (uc *updatesCache) CheckNow() error {
|
||||||
|
if debugging {
|
||||||
|
log.Info("[update check] Checking for update now.")
|
||||||
|
}
|
||||||
uc.mu.Lock()
|
uc.mu.Lock()
|
||||||
defer uc.mu.Unlock()
|
defer uc.mu.Unlock()
|
||||||
uc.lastCheck = time.Now()
|
uc.lastCheck = time.Now()
|
||||||
latestRemote, err := newVersionCheck()
|
latestRemote, err := newVersionCheck()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error("[update check] Failed: %v", err)
|
||||||
uc.checkError = err
|
uc.checkError = err
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -109,6 +114,9 @@ func (app *App) InitUpdates() {
|
||||||
|
|
||||||
func newVersionCheck() (string, error) {
|
func newVersionCheck() (string, error) {
|
||||||
res, err := http.Get("https://version.writefreely.org")
|
res, err := http.Get("https://version.writefreely.org")
|
||||||
|
if debugging {
|
||||||
|
log.Info("[update check] GET https://version.writefreely.org")
|
||||||
|
}
|
||||||
if err == nil && res.StatusCode == http.StatusOK {
|
if err == nil && res.StatusCode == http.StatusOK {
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue