Skip to content

Commit

Permalink
Merge branch 'main' into text-copy-handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Terry Howe authored Jul 17, 2024
2 parents fe45e9e + 9e5e766 commit 99520bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
14 changes: 14 additions & 0 deletions cmd/oras/internal/display/status/progress/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"sync"
"time"

ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"oras.land/oras/cmd/oras/internal/display/status/console"
)

Expand All @@ -39,6 +40,7 @@ type Status chan *status
// Manager is progress view master
type Manager interface {
Add() (Status, error)
SendAndStop(desc ocispec.Descriptor, prompt string) error
Close() error
}

Expand Down Expand Up @@ -120,6 +122,18 @@ func (m *manager) Add() (Status, error) {
return m.statusChan(s), nil
}

// SendAndStop send message for descriptor and stop timing.
func (m *manager) SendAndStop(desc ocispec.Descriptor, prompt string) error {
status, err := m.Add()
if err != nil {
return err
}
defer close(status)
status <- NewStatusMessage(prompt, desc, desc.Size)
status <- EndTiming()
return nil
}

func (m *manager) statusChan(s *status) Status {
ch := make(chan *status, BufferSize)
m.updating.Add(1)
Expand Down
9 changes: 1 addition & 8 deletions cmd/oras/internal/display/status/track/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,5 @@ func (t *graphTarget) Close() error {

// Prompt prompts the user with the provided prompt and descriptor.
func (t *graphTarget) Prompt(desc ocispec.Descriptor, prompt string) error {
status, err := t.manager.Add()
if err != nil {
return err
}
defer close(status)
status <- progress.NewStatusMessage(prompt, desc, desc.Size)
status <- progress.EndTiming()
return nil
return t.manager.SendAndStop(desc, prompt)
}

0 comments on commit 99520bf

Please sign in to comment.