diff --git a/Makefile b/Makefile index c3b01022..86f0ba30 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ lint: cyclo: @echo "Running $@:" - @test -z "$$(gocyclo -over 16 . | grep -v Godeps/_workspace/src/ | tee /dev/stderr)" + @test -z "$$(gocyclo -over 17 . | grep -v Godeps/_workspace/src/ | tee /dev/stderr)" deadcode: @echo "Running $@:" diff --git a/cmd-cp.go b/cmd-cp.go index 181ef512..517b5ff5 100644 --- a/cmd-cp.go +++ b/cmd-cp.go @@ -90,7 +90,7 @@ func doCopy(sourceURL string, targetURL string, bar *barSend) error { // set up progress newReader = bar.NewProxyReader(reader) } - + runtime.Gosched() // Yield more CPU err = putTarget(targetURL, length, newReader) if err != nil { if !globalQuietFlag { @@ -145,7 +145,7 @@ func doCopyCmd(sourceURLs []string, targetURL string, bar barSend) <-chan error } if !globalQuietFlag { bar.Extend(cpURLs.SourceContent.Size) - lock.Up() // Let copy routine know that it is catch up. + lock.Up() // Let copy routine know that it has to catch up. } } }(sourceURLs, targetURL) diff --git a/cmd-sync.go b/cmd-sync.go index 418d5d92..fbc5258e 100644 --- a/cmd-sync.go +++ b/cmd-sync.go @@ -94,7 +94,7 @@ func doSync(sURLs syncURLs, bar *barSend) error { // set up progress newReader = bar.NewProxyReader(reader) } - + runtime.Gosched() // Yield more CPU for err := range putTargets(targetURLs, length, newReader) { if err != nil { if !globalQuietFlag { @@ -155,7 +155,7 @@ func runSyncCmd(ctx *cli.Context) { } if !globalQuietFlag { bar.Extend(sURLs.SourceContent.Size) - lock.Up() // Let copy routine know that it is catch up. + lock.Up() // Let copy routine know that it has to catch up. } } }(sourceURL, targetURLs) diff --git a/cp-url.go b/cp-url.go index 24def378..dc3ac81a 100644 --- a/cp-url.go +++ b/cp-url.go @@ -198,7 +198,7 @@ func prepareCopyURLsTypeB(sourceURL string, targetURL string) *cpURLs { // SINGLE SOURCE - Type C: copy(d1..., d2) -> []copy(d1/f, d1/d2/f) -> []A // prepareCopyRecursiveURLTypeC - prepares target and source URLs for copying. func prepareCopyURLsTypeC(sourceURL, targetURL string) <-chan *cpURLs { - cpURLsCh := make(chan *cpURLs) + cpURLsCh := make(chan *cpURLs, 10000) go func(sourceURL, targetURL string, cpURLsCh chan *cpURLs) { defer close(cpURLsCh) if !isURLRecursive(sourceURL) { @@ -297,8 +297,7 @@ func prepareCopyURLsTypeC(sourceURL, targetURL string) <-chan *cpURLs { // MULTI-SOURCE - Type D: copy([]f, d) -> []B // prepareCopyURLsTypeD - prepares target and source URLs for copying. func prepareCopyURLsTypeD(sourceURLs []string, targetURL string) <-chan *cpURLs { - cpURLsCh := make(chan *cpURLs) - + cpURLsCh := make(chan *cpURLs, 10000) go func(sourceURLs []string, targetURL string, cpURLsCh chan *cpURLs) { defer close(cpURLsCh) @@ -347,8 +346,7 @@ func prepareCopyURLsTypeD(sourceURLs []string, targetURL string) <-chan *cpURLs // prepareCopyURLs - prepares target and source URLs for copying. func prepareCopyURLs(sourceURLs []string, targetURL string) <-chan *cpURLs { - cpURLsCh := make(chan *cpURLs) - + cpURLsCh := make(chan *cpURLs, 10000) go func(sourceURLs []string, targetURL string, cpURLsCh chan *cpURLs) { defer close(cpURLsCh) switch guessCopyURLType(sourceURLs, targetURL) { diff --git a/sync-url.go b/sync-url.go index 60a25d66..4c07c547 100644 --- a/sync-url.go +++ b/sync-url.go @@ -78,7 +78,7 @@ func guessSyncURLType(sourceURL string, targetURLs []string) syncURLsType { } func prepareSyncURLsTypeA(sourceURL string, targetURLs []string) <-chan syncURLs { - syncURLsCh := make(chan syncURLs) + syncURLsCh := make(chan syncURLs, 10000) go func() { defer close(syncURLsCh) var sURLs syncURLs @@ -97,7 +97,7 @@ func prepareSyncURLsTypeA(sourceURL string, targetURLs []string) <-chan syncURLs } func prepareSyncURLsTypeB(sourceURL string, targetURLs []string) <-chan syncURLs { - syncURLsCh := make(chan syncURLs) + syncURLsCh := make(chan syncURLs, 10000) go func() { defer close(syncURLsCh) var sURLs syncURLs @@ -116,7 +116,7 @@ func prepareSyncURLsTypeB(sourceURL string, targetURLs []string) <-chan syncURLs } func prepareSyncURLsTypeC(sourceURL string, targetURLs []string) <-chan syncURLs { - syncURLsCh := make(chan syncURLs) + syncURLsCh := make(chan syncURLs, 10000) go func() { defer close(syncURLsCh) if !isURLRecursive(sourceURL) { @@ -214,7 +214,7 @@ func prepareSyncURLsTypeC(sourceURL string, targetURLs []string) <-chan syncURLs // prepareCopyURLs - prepares target and source URLs for syncing. func prepareSyncURLs(sourceURL string, targetURLs []string) <-chan syncURLs { - syncURLsCh := make(chan syncURLs) + syncURLsCh := make(chan syncURLs, 10000) go func() { defer close(syncURLsCh) switch guessSyncURLType(sourceURL, targetURLs) {