diff --git a/cmd/oras/internal/display/status/track/reader.go b/cmd/oras/internal/display/status/track/reader.go index 456cc4dfd..0a1e046d9 100644 --- a/cmd/oras/internal/display/status/track/reader.go +++ b/cmd/oras/internal/display/status/track/reader.go @@ -46,13 +46,13 @@ func NewReader(r io.Reader, descriptor ocispec.Descriptor, actionPrompt string, } func managedReader(r io.Reader, descriptor ocispec.Descriptor, manager track.Manager) (*reader, error) { - tracker, err := track.NewReadTracker(manager, descriptor, r) + tracker, err := manager.Track(descriptor) if err != nil { return nil, err } return &reader{ - ReadTracker: tracker, + ReadTracker: track.NewReadTracker(tracker, r), manager: manager, }, nil } diff --git a/internal/experimental/track/reader.go b/internal/experimental/track/reader.go index a5533f1eb..8b0ac862d 100644 --- a/internal/experimental/track/reader.go +++ b/internal/experimental/track/reader.go @@ -2,8 +2,6 @@ package track import ( "io" - - ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) // ReadTracker tracks the transmission based on the read operation. @@ -13,16 +11,12 @@ type ReadTracker struct { offset int64 } -// NewReadTracker returns a new ReadTracker. -func NewReadTracker(manager Manager, descriptor ocispec.Descriptor, r io.Reader) (*ReadTracker, error) { - tracker, err := manager.Track(descriptor) - if err != nil { - return nil, err - } +// NewReadTracker attaches a tracker to a reader. +func NewReadTracker(track Tracker, r io.Reader) *ReadTracker { return &ReadTracker{ base: r, - tracker: tracker, - }, nil + tracker: track, + } } // Read reads from the base reader and updates the status.