Skip to content

Commit 575f989

Browse files
author
cnbattle
committed
fix 并发上传丢失文件问题
1 parent 5f7d32d commit 575f989

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

upcloud.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,19 @@ func main() {
3939
var wg sync.WaitGroup
4040
for _, file := range files {
4141
wg.Add(1)
42-
_ = pool.Submit(func() {
43-
err := commInterface.Upload(file.Local, file.UpKey)
42+
local := file.Local
43+
upKey := file.UpKey
44+
err = pool.Submit(func() {
45+
err := commInterface.Upload(local, upKey)
4446
if err != nil {
4547
fmt.Println("commInterface.Upload error:", err)
4648
}
4749
fmt.Print(".")
4850
wg.Done()
4951
})
52+
if err != nil {
53+
fmt.Println("pool.Submit error:", err)
54+
}
5055
}
5156
wg.Wait()
5257
fmt.Println()

0 commit comments

Comments
 (0)