Skip to content

Commit

Permalink
Merge pull request #5597 from bpaquet/fix_5584
Browse files Browse the repository at this point in the history
[s3 cache] Fix upload of downloaded layer
  • Loading branch information
tonistiigi authored Feb 11, 2025
2 parents 0e3037c + 914c553 commit c4f673e
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 c4f673e

Please sign in to comment.