From 0804fadbb54bf3d18d03ad14f0a587188c592690 Mon Sep 17 00:00:00 2001 From: velvettear Date: Fri, 22 Sep 2023 15:54:02 +0200 Subject: [PATCH] fixed order of the progress bars --- .vscode/launch.json | 4 +++- tools/rsync.go | 13 ++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 46226a0..8088056 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -30,7 +30,9 @@ "--password", "$Velvet90", "--concurrency", - "4", + "12", + "--delay", + "250", "--verbose", ], "console": "integratedTerminal" diff --git a/tools/rsync.go b/tools/rsync.go index 04c9dfb..c94660c 100644 --- a/tools/rsync.go +++ b/tools/rsync.go @@ -43,24 +43,23 @@ func Transfer() { if concurrency == 0 { concurrency = sourcefilesCount } - first := true + index := 0 channel := make(chan struct{}, concurrency) for file, size := range sourcefiles { channel <- struct{}{} - if !first { + if index > 0 { time.Sleep(settings.Delay) - } else { - first = false } - go func(file string, size int64) { + go func(file string, size int64, index int) { defer waitgroup.Done() - bar := createProgressBar(barcontainer, filepath.Base(file), size, int64(100), counter, false) + bar := createProgressBar(barcontainer, filepath.Base(file), size, int64(100), index, false) if transferFile(bar, file) { counter++ } totalbar.Increment() <-channel - }(file, size) + }(file, size, index) + index++ } barcontainer.Wait() timeDifference := time.Since(timestamp)