fixed order of the progress bars

This commit is contained in:
Daniel Sommer 2023-09-22 15:54:02 +02:00
parent 7bdce49c72
commit 0804fadbb5
2 changed files with 9 additions and 8 deletions

4
.vscode/launch.json vendored
View file

@ -30,7 +30,9 @@
"--password",
"$Velvet90",
"--concurrency",
"4",
"12",
"--delay",
"250",
"--verbose",
],
"console": "integratedTerminal"

View file

@ -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)