MCPcopy
hub / github.com/kopia/kopia / PrefetchBlob

Method PrefetchBlob

internal/cache/content_cache.go:150–168  ·  view source on GitHub ↗
(ctx context.Context, blobID blob.ID)

Source from the content-addressed store, hash-verified

148}
149
150func (c *contentCacheImpl) PrefetchBlob(ctx context.Context, blobID blob.ID) error {
151 var blobData gather.WriteBuffer
152 defer blobData.Close()
153
154 // see if it's already cached before taking a lock
155 if c.pc.getPartial(ctx, BlobIDCacheKey(blobID), 0, 1, &blobData) {
156 return nil
157 }
158
159 // acquire exclusive lock for the blob.
160 c.pc.exclusiveLock(string(blobID))
161 defer c.pc.exclusiveUnlock(string(blobID))
162
163 if c.pc.getPartial(ctx, BlobIDCacheKey(blobID), 0, 1, &blobData) {
164 return nil
165 }
166
167 return c.fetchBlobInternal(ctx, blobID, &blobData)
168}
169
170func (c *contentCacheImpl) CacheStorage() Storage {
171 return c.pc.cacheStorage

Callers

nothing calls this directly

Calls 6

CloseMethod · 0.95
fetchBlobInternalMethod · 0.95
BlobIDCacheKeyFunction · 0.85
getPartialMethod · 0.80
exclusiveLockMethod · 0.45
exclusiveUnlockMethod · 0.45

Tested by

no test coverage detected