MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / loadRemoteWithCache

Function loadRemoteWithCache

internal/repoconfig/repoconfig.go:250–285  ·  view source on GitHub ↗
(url string, kind entities.Kind, cache camconfig.CacheConfig)

Source from the content-addressed store, hash-verified

248}
249
250func loadRemoteWithCache(url string, kind entities.Kind, cache camconfig.CacheConfig) (map[string]RepoEntry, error) {
251 if cache.Enabled {
252 if cached, err := loadFromCache(url, kind, cache); err == nil && cached != nil {
253 return cached, nil
254 }
255 }
256
257 client := fetching.New()
258 tmp, err := os.CreateTemp("", "cam-repocfg-*.json")
259 if err != nil {
260 return nil, err
261 }
262 tmpPath := tmp.Name()
263 tmp.Close()
264 defer os.Remove(tmpPath)
265
266 if err := client.FetchFile(url, tmpPath); err != nil {
267 return nil, err
268 }
269
270 data, err := os.ReadFile(tmpPath)
271 if err != nil {
272 return nil, err
273 }
274
275 repos, err := parseRepoJSON(data)
276 if err != nil {
277 return nil, err
278 }
279
280 if cache.Enabled {
281 _ = saveToCache(url, kind, cache, data)
282 }
283
284 return repos, nil
285}
286
287// ---------- disk cache -------------------------------------------------------
288

Callers 1

LoadAllFunction · 0.85

Calls 8

NewFunction · 0.92
loadFromCacheFunction · 0.85
parseRepoJSONFunction · 0.85
saveToCacheFunction · 0.85
FetchFileMethod · 0.80
ReadFileMethod · 0.80
NameMethod · 0.65
RemoveMethod · 0.45

Tested by

no test coverage detected