fixed order of the progress bars
This commit is contained in:
parent
7bdce49c72
commit
0804fadbb5
2 changed files with 9 additions and 8 deletions
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
|
@ -30,7 +30,9 @@
|
||||||
"--password",
|
"--password",
|
||||||
"$Velvet90",
|
"$Velvet90",
|
||||||
"--concurrency",
|
"--concurrency",
|
||||||
"4",
|
"12",
|
||||||
|
"--delay",
|
||||||
|
"250",
|
||||||
"--verbose",
|
"--verbose",
|
||||||
],
|
],
|
||||||
"console": "integratedTerminal"
|
"console": "integratedTerminal"
|
||||||
|
|
|
@ -43,24 +43,23 @@ func Transfer() {
|
||||||
if concurrency == 0 {
|
if concurrency == 0 {
|
||||||
concurrency = sourcefilesCount
|
concurrency = sourcefilesCount
|
||||||
}
|
}
|
||||||
first := true
|
index := 0
|
||||||
channel := make(chan struct{}, concurrency)
|
channel := make(chan struct{}, concurrency)
|
||||||
for file, size := range sourcefiles {
|
for file, size := range sourcefiles {
|
||||||
channel <- struct{}{}
|
channel <- struct{}{}
|
||||||
if !first {
|
if index > 0 {
|
||||||
time.Sleep(settings.Delay)
|
time.Sleep(settings.Delay)
|
||||||
} else {
|
|
||||||
first = false
|
|
||||||
}
|
}
|
||||||
go func(file string, size int64) {
|
go func(file string, size int64, index int) {
|
||||||
defer waitgroup.Done()
|
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) {
|
if transferFile(bar, file) {
|
||||||
counter++
|
counter++
|
||||||
}
|
}
|
||||||
totalbar.Increment()
|
totalbar.Increment()
|
||||||
<-channel
|
<-channel
|
||||||
}(file, size)
|
}(file, size, index)
|
||||||
|
index++
|
||||||
}
|
}
|
||||||
barcontainer.Wait()
|
barcontainer.Wait()
|
||||||
timeDifference := time.Since(timestamp)
|
timeDifference := time.Since(timestamp)
|
||||||
|
|
Loading…
Reference in a new issue