| @@ -135,90 +135,8 @@ func GetModelChunks(ctx *context.Context) { | |||||
| }) | }) | ||||
| } | } | ||||
| } | } | ||||
| // //使用description存储模型信息 | |||||
| // dbmodeluuid := attach.Description | |||||
| // modelname := "" | |||||
| // if dbmodeluuid != modeluuid { | |||||
| // log.Info("The file has uploaded.fileChunk.ObjectName=" + fileChunk.ObjectName + " typeCloudBrain=" + fmt.Sprint(typeCloudBrain)) | |||||
| // isExist := copyModelAttachmentFile(typeCloudBrain, fileChunk, fileName, modeluuid) | |||||
| // if isExist { | |||||
| // model, err := models.QueryModelById(modeluuid) | |||||
| // if err == nil && model != nil { | |||||
| // modelname = model.Name | |||||
| // } | |||||
| // ctx.JSON(200, map[string]string{ | |||||
| // "uuid": fileChunk.UUID, | |||||
| // "uploaded": strconv.Itoa(fileChunk.IsUploaded), | |||||
| // "uploadID": fileChunk.UploadID, | |||||
| // "chunks": string(chunks), | |||||
| // "attachID": strconv.Itoa(int(attachID)), | |||||
| // "modeluuid": modeluuid, | |||||
| // "fileName": attach.Name, | |||||
| // "modelName": modelname, | |||||
| // }) | |||||
| // } else { | |||||
| // UpdateModelSize(modeluuid) | |||||
| // ctx.JSON(200, map[string]string{ | |||||
| // "uuid": fileChunk.UUID, | |||||
| // "uploaded": strconv.Itoa(fileChunk.IsUploaded), | |||||
| // "uploadID": fileChunk.UploadID, | |||||
| // "chunks": string(chunks), | |||||
| // "attachID": strconv.Itoa(int(attachID)), | |||||
| // "fileName": attach.Name, | |||||
| // }) | |||||
| // } | |||||
| // return | |||||
| // } else { | |||||
| // model, err := models.QueryModelById(dbmodeluuid) | |||||
| // if err == nil { | |||||
| // modelname = model.Name | |||||
| // } | |||||
| // ctx.JSON(200, map[string]string{ | |||||
| // "uuid": fileChunk.UUID, | |||||
| // "uploaded": strconv.Itoa(fileChunk.IsUploaded), | |||||
| // "uploadID": fileChunk.UploadID, | |||||
| // "chunks": string(chunks), | |||||
| // "attachID": strconv.Itoa(int(attachID)), | |||||
| // "modeluuid": dbmodeluuid, | |||||
| // "fileName": attach.Name, | |||||
| // "modelName": modelname, | |||||
| // }) | |||||
| // return | |||||
| // } | |||||
| } | } | ||||
| // func copyModelAttachmentFile(typeCloudBrain int, fileChunk *models.ModelFileChunk, fileName, modeluuid string) bool { | |||||
| // srcObjectName := fileChunk.ObjectName | |||||
| // var isExist bool | |||||
| // //copy | |||||
| // destObjectName := getObjectName(fileName, modeluuid) | |||||
| // if typeCloudBrain == models.TypeCloudBrainOne { | |||||
| // bucketName := setting.Attachment.Minio.Bucket | |||||
| // log.Info("minio copy..srcObjectName=" + srcObjectName + " bucketName=" + bucketName) | |||||
| // if storage.MinioGetFilesSize(bucketName, []string{destObjectName}) > 0 { | |||||
| // isExist = true | |||||
| // } else { | |||||
| // log.Info("minio copy..srcObjectName=" + srcObjectName + " bucketName=" + bucketName) | |||||
| // storage.MinioCopyAFile(bucketName, srcObjectName, bucketName, destObjectName) | |||||
| // } | |||||
| // } else { | |||||
| // bucketName := setting.Bucket | |||||
| // log.Info("obs copy..srcObjectName=" + srcObjectName + " bucketName=" + bucketName + " destObjectName=" + destObjectName) | |||||
| // size := storage.ObsGetFilesSize(bucketName, []string{destObjectName}) | |||||
| // log.Info("size=" + fmt.Sprint(size)) | |||||
| // if size > 0 { | |||||
| // isExist = true | |||||
| // } else { | |||||
| // log.Info("obs copy..srcObjectName=" + srcObjectName + " bucketName=" + bucketName) | |||||
| // storage.ObsCopyFile(bucketName, srcObjectName, bucketName, destObjectName) | |||||
| // } | |||||
| // } | |||||
| // return isExist | |||||
| // } | |||||
| func getObjectName(filename string, modeluuid string) string { | func getObjectName(filename string, modeluuid string) string { | ||||
| return strings.TrimPrefix(path.Join(Model_prefix, path.Join(modeluuid[0:1], modeluuid[1:2], modeluuid, filename)), "/") | return strings.TrimPrefix(path.Join(Model_prefix, path.Join(modeluuid[0:1], modeluuid[1:2], modeluuid, filename)), "/") | ||||
| } | } | ||||