MCPcopy Create free account
hub / github.com/Facets-cloud/flow / fetchAndCacheLatest

Function fetchAndCacheLatest

internal/app/release.go:87–117  ·  view source on GitHub ↗
(cachePath string)

Source from the content-addressed store, hash-verified

85}
86
87func fetchAndCacheLatest(cachePath string) string {
88 resp, err := httpGetForVersion(githubLatestReleaseURL)
89 if err != nil {
90 return ""
91 }
92 defer resp.Body.Close()
93 if resp.StatusCode != 200 {
94 return ""
95 }
96 var rel struct {
97 TagName string `json:"tag_name"`
98 }
99 if err := json.NewDecoder(resp.Body).Decode(&rel); err != nil {
100 return ""
101 }
102 if rel.TagName == "" {
103 return ""
104 }
105 cache := versionCache{
106 CheckedAt: nowForVersion(),
107 LatestVersion: rel.TagName,
108 }
109 raw, err := json.MarshalIndent(cache, "", " ")
110 if err != nil {
111 return rel.TagName
112 }
113 if err := os.MkdirAll(filepath.Dir(cachePath), 0o755); err == nil {
114 _ = os.WriteFile(cachePath, raw, 0o644)
115 }
116 return rel.TagName
117}

Callers 1

LatestReleaseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected