Skip to content

Commit

Permalink
fix 并发上传丢失文件问题
Browse files Browse the repository at this point in the history
  • Loading branch information
cnbattle committed Mar 5, 2021
1 parent 5f7d32d commit 575f989
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions upcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,19 @@ func main() {
var wg sync.WaitGroup
for _, file := range files {
wg.Add(1)
_ = pool.Submit(func() {
err := commInterface.Upload(file.Local, file.UpKey)
local := file.Local
upKey := file.UpKey
err = pool.Submit(func() {
err := commInterface.Upload(local, upKey)
if err != nil {
fmt.Println("commInterface.Upload error:", err)
}
fmt.Print(".")
wg.Done()
})
if err != nil {
fmt.Println("pool.Submit error:", err)
}
}
wg.Wait()
fmt.Println()
Expand Down

0 comments on commit 575f989

Please sign in to comment.