Merge pull request #727 from vadmeste/pr_out_show_current_copied_file

Make copying command more informative especially with several source files
This commit is contained in:
Harshavardhana
2015-06-02 13:18:55 -07:00
2 changed files with 10 additions and 0 deletions
+3
View File
@@ -69,6 +69,9 @@ EXAMPLES:
// doCopy - Copy a singe file from source to destination
func doCopy(sourceURL string, sourceConfig *hostConfig, targetURL string, targetConfig *hostConfig, bar *barSend) error {
if !globalQuietFlag {
bar.SetPrefix(sourceURL + ": ")
}
reader, length, err := getSource(sourceURL, sourceConfig)
if err != nil {
if !globalQuietFlag {
+7
View File
@@ -33,6 +33,7 @@ const (
cpBarCmdFinish
cpBarCmdPutError
cpBarCmdGetError
cpBarCmdSetPrefix
)
type copyReader struct {
@@ -76,6 +77,10 @@ func (b *barSend) NewProxyReader(r io.Reader) *copyReader {
return &copyReader{r, b}
}
func (b *barSend) SetPrefix(prefix string) {
b.cmdCh <- barMsg{Cmd: cpBarCmdSetPrefix, Arg: prefix}
}
func (b barSend) Finish() {
defer close(b.cmdCh)
b.cmdCh <- barMsg{Cmd: cpBarCmdFinish}
@@ -102,6 +107,8 @@ func newCpBar() barSend {
bar.Format("[=> ]")
for msg := range cmdCh {
switch msg.Cmd {
case cpBarCmdSetPrefix:
bar.Prefix(msg.Arg.(string))
case cpBarCmdExtend:
atomic.AddInt64(&bar.Total, msg.Arg.(int64))
if bar.Total > 0 && !started {