From e03315ba444986b3fc90bfd9754d8491f56a3426 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 8 Oct 2015 16:24:11 -0700 Subject: [PATCH] Add cursor animate to mirror --- diff.go | 22 ---------------------- mirror-url.go | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/diff.go b/diff.go index b360ad58..1f61ba46 100644 --- a/diff.go +++ b/diff.go @@ -19,7 +19,6 @@ package main import ( "encoding/json" "strings" - "time" "github.com/minio/mc/pkg/client" "github.com/minio/mc/pkg/console" @@ -232,27 +231,6 @@ func dodiffRecursive(firstClnt, secondClnt client.Client, ch chan DiffMessage) { return } - doneCh := make(chan bool) - defer close(doneCh) - go func(doneCh <-chan bool) { - cursorCh := cursorAnimate() - for { - select { - case <-time.Tick(100 * time.Millisecond): - if !globalQuietFlag && !globalJSONFlag { - console.PrintC("\r" + "Scanning.. " + string(<-cursorCh)) - } - case <-doneCh: - return - } - } - }(doneCh) - doneCh <- true - - if !globalQuietFlag && !globalJSONFlag { - console.Eraseline() - } - fch := firstClnt.List(true) sch := secondClnt.List(true) f, fok := <-fch diff --git a/mirror-url.go b/mirror-url.go index ad6c3eb6..2b55164b 100644 --- a/mirror-url.go +++ b/mirror-url.go @@ -20,9 +20,11 @@ import ( "fmt" "strconv" "strings" + "time" "github.com/minio/cli" "github.com/minio/mc/pkg/client" + "github.com/minio/mc/pkg/console" "github.com/minio/minio/pkg/probe" ) @@ -102,6 +104,22 @@ func deltaSourceTargets(sourceClnt client.Client, targetClnts []client.Client) < defer close(mirrorURLsCh) id := newRandomID(8) + doneCh := make(chan bool) + defer close(doneCh) + go func(doneCh <-chan bool) { + cursorCh := cursorAnimate() + for { + select { + case <-time.Tick(100 * time.Millisecond): + if !globalQuietFlag && !globalJSONFlag { + console.PrintC("\r" + "Scanning.. " + string(<-cursorCh)) + } + case <-doneCh: + return + } + } + }(doneCh) + sourceSortedList := sortedList{} targetSortedList := make([]*sortedList, len(targetClnts)) @@ -161,6 +179,10 @@ func deltaSourceTargets(sourceClnt client.Client, targetClnts []client.Client) < } } } + doneCh <- true + if !globalQuietFlag && !globalJSONFlag { + console.Eraseline() + } }() return mirrorURLsCh }