MCPcopy Create free account
hub / github.com/MertJSX/folderhost / checkForUpdates

Function checkForUpdates

utils/version_checker.go:77–103  ·  view source on GitHub ↗
(currentVersion string)

Source from the content-addressed store, hash-verified

75}
76
77func checkForUpdates(currentVersion string) (bool, string) {
78 client := http.Client{
79 Timeout: 5 * time.Second,
80 }
81
82 resp, err := client.Get("https://api.folderhost.org/v1/folderhost/version-check")
83 if err != nil {
84 return false, currentVersion
85 }
86 defer resp.Body.Close()
87
88 body, err := io.ReadAll(resp.Body)
89 if err != nil {
90 return false, currentVersion
91 }
92
93 var versionResp VersionResponse
94 if err := json.Unmarshal(body, &versionResp); err != nil {
95 return false, currentVersion
96 }
97
98 if isNewerVersion(currentVersion, versionResp.Version) {
99 return true, versionResp.Version
100 }
101
102 return false, currentVersion
103}
104
105func checkAndNotifyVersion(currentVersion string) {
106 hasUpdate, newVersion := checkForUpdates(currentVersion)

Callers 1

checkAndNotifyVersionFunction · 0.85

Calls 2

isNewerVersionFunction · 0.85
GetMethod · 0.80

Tested by

no test coverage detected