remotes/docker: implement seekable http requests

To support resumable download, the fetcher for a remote must implement
`io.Seeker`. If implemented the `content.Copy` function will detect the
seeker and begin from where the download was terminated by a previous
attempt.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day
2017-11-01 16:11:40 -07:00
committed by Michael Crosby
parent a9308e174d
commit 682151b166
4 changed files with 176 additions and 23 deletions

View File

@@ -2,7 +2,6 @@ package content
import (
"context"
"fmt"
"io"
"sync"
@@ -119,7 +118,7 @@ func seekReader(r io.Reader, offset, size int64) (io.Reader, error) {
if ok {
nn, err := seeker.Seek(offset, io.SeekStart)
if nn != offset {
return nil, fmt.Errorf("failed to seek to offset %v", offset)
return nil, errors.Wrapf(err, "failed to seek to offset %v", offset)
}
if err != nil {