MCPcopy Index your code
hub / github.com/coder/coder / newBinMetadataCache

Function newBinMetadataCache

site/bin.go:311–331  ·  view source on GitHub ↗
(binFS http.FileSystem, binSha1Hashes map[string]string)

Source from the content-addressed store, hash-verified

309}
310
311func newBinMetadataCache(binFS http.FileSystem, binSha1Hashes map[string]string) *binMetadataCache {
312 b := &binMetadataCache{
313 binFS: binFS,
314 originalHashes: make(map[string]string, len(binSha1Hashes)),
315
316 metadata: make(map[string]binMetadata, len(binSha1Hashes)),
317 mut: sync.RWMutex{},
318 sf: singleflight.Group{},
319 sem: make(chan struct{}, 4),
320 }
321
322 // Previously we copied binSha1Hashes to the cache immediately. Since we now
323 // read other information like size from the file, we can't do that. Instead
324 // we copy the hashes to a different map that will be used to populate the
325 // cache on the first request.
326 for k, v := range binSha1Hashes {
327 b.originalHashes[k] = v
328 }
329
330 return b
331}
332
333func (b *binMetadataCache) getMetadata(name string) (binMetadata, error) {
334 b.mut.RLock()

Callers 1

newBinHandlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected