CheckNow asks for the latest released version of writefreely and updates the cache last checked time. If the version postdates the current 'latest' the version value is replaced.
()
| 38 | // the cache last checked time. If the version postdates the current 'latest' |
| 39 | // the version value is replaced. |
| 40 | func (uc *updatesCache) CheckNow() error { |
| 41 | if debugging { |
| 42 | log.Info("[update check] Checking for update now.") |
| 43 | } |
| 44 | uc.mu.Lock() |
| 45 | defer uc.mu.Unlock() |
| 46 | uc.lastCheck = time.Now() |
| 47 | latestRemote, err := newVersionCheck() |
| 48 | if err != nil { |
| 49 | log.Error("[update check] Failed: %v", err) |
| 50 | uc.checkError = err |
| 51 | return err |
| 52 | } |
| 53 | if CompareSemver(latestRemote, uc.latestVersion) == 1 { |
| 54 | uc.latestVersion = latestRemote |
| 55 | } |
| 56 | return nil |
| 57 | } |
| 58 | |
| 59 | // AreAvailable updates the cache if the frequency duration has passed |
| 60 | // then returns if the latest release is newer than the current running version. |