Skip to content

Commit

Permalink
code clean
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah committed Oct 8, 2023
1 parent 3193b48 commit a46c218
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions cmd/oras/root/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,8 @@ func doCopy(ctx context.Context, src option.ReadOnlyGraphTagFinderTarget, dst or
committed.Store(desc.Digest.String(), desc.Annotations[ocispec.AnnotationTitle])
return tracked.Prompt(desc, "Exists ", opts.Verbose)
}
if opts.TTY != nil {
tracked, err = track.NewTarget(dst, "Copying ", "Copied ", opts.TTY)
if err != nil {
return ocispec.Descriptor{}, err
}
defer tracked.Close()
dst = tracked
} else {
switch opts.TTY {
case nil: // none tty output
extendedCopyOptions.PreCopy = func(ctx context.Context, desc ocispec.Descriptor) error {
return display.PrintStatus(desc, "Copying", opts.Verbose)
}
Expand All @@ -178,6 +172,13 @@ func doCopy(ctx context.Context, src option.ReadOnlyGraphTagFinderTarget, dst or
}
return display.PrintStatus(desc, "Copied ", opts.Verbose)
}
default: // tty output
tracked, err = track.NewTarget(dst, "Copying ", "Copied ", opts.TTY)
if err != nil {
return ocispec.Descriptor{}, err
}
defer tracked.Close()
dst = tracked
}

var desc ocispec.Descriptor
Expand Down

0 comments on commit a46c218

Please sign in to comment.