MCPcopy
hub / github.com/writefreely/writefreely / CheckNow

Method CheckNow

updates.go:40–57  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

38// the cache last checked time. If the version postdates the current 'latest'
39// the version value is replaced.
40func (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.

Callers 4

AreAvailableMethod · 0.95
newUpdatesCacheFunction · 0.95
handleViewAdminUpdatesFunction · 0.80
TestUpdatesRoundTripFunction · 0.80

Calls 2

newVersionCheckFunction · 0.85
CompareSemverFunction · 0.85

Tested by 1

TestUpdatesRoundTripFunction · 0.64