Fixed handleImages to properly capture loop variables (#4275)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
86aa979310
Коммит
6517b0f9e1
@@ -194,8 +194,8 @@ func doUploadFile(teamId string, channelId string, userId string, rawFilename st
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handleImages(previewPathList []string, thumbnailPathList []string, fileData [][]byte) {
|
func handleImages(previewPathList []string, thumbnailPathList []string, fileData [][]byte) {
|
||||||
for i := range fileData {
|
for i, data := range fileData {
|
||||||
go func() {
|
go func(i int, data []byte) {
|
||||||
// Decode image bytes into Image object
|
// Decode image bytes into Image object
|
||||||
img, imgType, err := image.Decode(bytes.NewReader(fileData[i]))
|
img, imgType, err := image.Decode(bytes.NewReader(fileData[i]))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -236,7 +236,7 @@ func handleImages(previewPathList []string, thumbnailPathList []string, fileData
|
|||||||
|
|
||||||
go generateThumbnailImage(img, thumbnailPathList[i], width, height)
|
go generateThumbnailImage(img, thumbnailPathList[i], width, height)
|
||||||
go generatePreviewImage(img, previewPathList[i], width)
|
go generatePreviewImage(img, previewPathList[i], width)
|
||||||
}()
|
}(i, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user