(ctx context.Context, blobID blob.ID, offset, length int64, output *gather.WriteBuffer)
| 62 | } |
| 63 | |
| 64 | func (c *contentCacheImpl) getContentFromFullBlob(ctx context.Context, blobID blob.ID, offset, length int64, output *gather.WriteBuffer) error { |
| 65 | c.pc.exclusiveLock(string(blobID)) |
| 66 | defer c.pc.exclusiveUnlock(string(blobID)) |
| 67 | |
| 68 | // check again to see if we perhaps lost the race and the data is now in cache. |
| 69 | if c.pc.getPartial(ctx, BlobIDCacheKey(blobID), offset, length, output) { |
| 70 | return nil |
| 71 | } |
| 72 | |
| 73 | var blobData gather.WriteBuffer |
| 74 | defer blobData.Close() |
| 75 | |
| 76 | if err := c.fetchBlobInternal(ctx, blobID, &blobData); err != nil { |
| 77 | return err |
| 78 | } |
| 79 | |
| 80 | if offset == 0 && length == -1 { |
| 81 | _, err := blobData.Bytes().WriteTo(output) |
| 82 | |
| 83 | return errors.Wrap(err, "error copying results") |
| 84 | } |
| 85 | |
| 86 | if offset < 0 || offset+length > int64(blobData.Length()) { |
| 87 | return errors.Errorf("invalid (offset=%v,length=%v) for blob %q of size %v", offset, length, blobID, blobData.Length()) |
| 88 | } |
| 89 | |
| 90 | output.Reset() |
| 91 | |
| 92 | impossible.PanicOnError(blobData.AppendSectionTo(output, int(offset), int(length))) |
| 93 | |
| 94 | return nil |
| 95 | } |
| 96 | |
| 97 | func (c *contentCacheImpl) fetchBlobInternal(ctx context.Context, blobID blob.ID, blobData *gather.WriteBuffer) error { |
| 98 | // read the entire blob |
no test coverage detected