Skip to content

Commit

Permalink
chunked: recalculate correctly the chunks to request
Browse files Browse the repository at this point in the history
after the missing parts are merged, it is necessary to recalculate the
chunks to ask to the server.

Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed May 11, 2022
1 parent 90fd24c commit 75fd4d6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkg/chunked/storage_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -1084,12 +1084,18 @@ func mergeMissingChunks(missingParts []missingPart, target int) []missingPart {

func (c *chunkedDiffer) retrieveMissingFiles(dest string, dirfd int, missingParts []missingPart, options *archive.TarOptions) error {
var chunksToRequest []ImageSourceChunk
for _, c := range missingParts {
if c.OriginFile == nil && !c.Hole {
chunksToRequest = append(chunksToRequest, *c.SourceChunk)

calculateChunksToRequest := func() {
chunksToRequest = []ImageSourceChunk{}
for _, c := range missingParts {
if c.OriginFile == nil && !c.Hole {
chunksToRequest = append(chunksToRequest, *c.SourceChunk)
}
}
}

calculateChunksToRequest()

// There are some missing files. Prepare a multirange request for the missing chunks.
var streams chan io.ReadCloser
var err error
Expand All @@ -1109,6 +1115,7 @@ func (c *chunkedDiffer) retrieveMissingFiles(dest string, dirfd int, missingPart

// Merge more chunks to request
missingParts = mergeMissingChunks(missingParts, requested/2)
calculateChunksToRequest()
continue
}
return err
Expand Down

0 comments on commit 75fd4d6

Please sign in to comment.