Skip to content

Commit

Permalink
[s3 cache] Fix upload of downloaded layer
Browse files Browse the repository at this point in the history
Signed-off-by: Bertrand Paquet <bertrand.paquet@gmail.com>
  • Loading branch information
bpaquet committed Jan 17, 2025
1 parent c2c70ac commit 914c553
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cache/remotecache/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,14 @@ func (s3Client *s3Client) getManifest(ctx context.Context, key string, config *v
return true, nil
}

func (s3Client *s3Client) getReader(ctx context.Context, key string) (io.ReadCloser, error) {
func (s3Client *s3Client) getReader(ctx context.Context, key string, offset int64) (io.ReadCloser, error) {
input := &s3.GetObjectInput{
Bucket: &s3Client.bucket,
Key: &key,
}
if offset > 0 {
input.Range = aws.String(fmt.Sprintf("bytes=%d-", offset))
}

output, err := s3Client.GetObject(ctx, input)
if err != nil {
Expand Down Expand Up @@ -588,7 +591,7 @@ func (s3Client *s3Client) touch(ctx context.Context, key string, size *int64) (e

func (s3Client *s3Client) ReaderAt(ctx context.Context, desc ocispecs.Descriptor) (content.ReaderAt, error) {
readerAtCloser := toReaderAtCloser(func(offset int64) (io.ReadCloser, error) {
return s3Client.getReader(ctx, s3Client.blobKey(desc.Digest))
return s3Client.getReader(ctx, s3Client.blobKey(desc.Digest), offset)
})
return &readerAt{ReaderAtCloser: readerAtCloser, size: desc.Size}, nil
}
Expand Down

0 comments on commit 914c553

Please sign in to comment.