Commit 8570754f by Li Feifei

test

parent c8ce46fa
Pipeline #14620 failed with stages
in 39 seconds
......@@ -11,6 +11,7 @@ import (
"github.com/aliyun/aliyun-oss-go-sdk/oss"
"github.com/astaxie/beego/orm"
"github.com/chai2010/webp"
"github.com/xxjwxc/gowp/workpool"
"image"
"image/jpeg"
"image/png"
......@@ -27,6 +28,7 @@ import (
"runtime/debug"
"strconv"
"strings"
"sync"
"time"
)
......@@ -36,13 +38,19 @@ var (
WEBURL string = "https://test-live.offcncloud.com"
client *http.Client
token string
once sync.Once
Pool *workpool.WorkPool
)
const docUrl string = "http://doc.offcncloud.com/"
func init() {
once.Do(func() {
Pool = workpool.New(10)
})
}
//func main() {
......@@ -253,44 +261,58 @@ func Down(v *models.XyuSmallTempFiles) {
ch1 := make(chan bool)
for _, file := range reader.File {
go func(file *zip.File) {
defer debug.FreeOSMemory()
err := pdfThumbnail(objectPath, file, bucket)
if err != nil {
fmt.Println(objectPath + file.Name + "上传失败")
// 上传缩略图失败,重试3次
Pool.DoWait(func() error {
var err error
for i := 0; i < 3; i++ {
err = pdfThumbnail(objectPath, file, bucket)
if err == nil {
ch1 <- true
return
}
}
UpdateFileError("5", v.Uuid, v.RoomNum, objectName)
ch1 <- false
return
} else {
ch1 <- true
return
}
}(file)
if err = pdfThumbnail(objectPath, file, bucket); err == nil {
break
}
for i := 0; i < int(wordFloat64); i++ {
t := <-ch1
if t {
uploadImageCount++
}
return err
})
//go func(file *zip.File) {
// defer debug.FreeOSMemory()
// err := pdfThumbnail(objectPath, file, bucket)
//
// if err != nil {
// fmt.Println(objectPath + file.Name + "上传失败")
// // 上传缩略图失败,重试3次
// for i := 0; i < 3; i++ {
// err = pdfThumbnail(objectPath, file, bucket)
// if err == nil {
// ch1 <- true
// return
// }
// }
// UpdateFileError("5", v.Uuid, v.RoomNum, objectName)
// ch1 <- false
// return
// } else {
// ch1 <- true
// return
// }
//
//}(file)
}
defer reader.Close()
fmt.Println(uploadImageCount, wordFloat64)
if uploadImageCount != wordFloat64 {
//for i := 0; i < int(wordFloat64); i++ {
// t := <-ch1
// if t {
// uploadImageCount++
// }
//}
err = Pool.Wait()
if err != nil {
UpdateFileError("5", v.Uuid, v.RoomNum, objectName)
fmt.Println("上传失败")
fmt.Println(err)
return
}
defer reader.Close()
//fmt.Println(uploadImageCount, wordFloat64)
//if uploadImageCount != wordFloat64 {
// UpdateFileError("5", v.Uuid, v.RoomNum, objectName)
// fmt.Println("上传失败")
// return
//}
go func() {
err := uploadPacked(bucket, filename, contentHash, objectPath,
......@@ -487,6 +509,7 @@ func CreateFileDataBase(room_file map[string]interface{}) error {
return nil
}
func pdfThumbnail(objectPath string, file *zip.File, bucket *oss.Bucket) error {
fc, err := file.Open()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment