You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ai_model.go 975 B

123456789101112131415161718192021222324252627282930
  1. package cloudbrainTask
  2. import (
  3. "code.gitea.io/gitea/models"
  4. "code.gitea.io/gitea/modules/log"
  5. "code.gitea.io/gitea/modules/setting"
  6. "code.gitea.io/gitea/modules/storage"
  7. )
  8. func IsModelFileExists(model *models.AiModelManage, fileName string) bool {
  9. if model.Type == models.TypeCloudBrainTwo {
  10. key := models.AIModelPath + models.AttachmentRelativePath(model.ID) + "/" + fileName
  11. log.Info("IsModelFileExists TypeCloudBrainTwo key=%s", key)
  12. isExist, err := storage.IsObjectExist4Obs(setting.Bucket, key)
  13. if err != nil {
  14. return false
  15. }
  16. return isExist
  17. } else if model.Type == models.TypeCloudBrainOne {
  18. prefix := models.AIModelPath + models.AttachmentRelativePath(model.ID) + "/"
  19. objectName := prefix + fileName
  20. log.Info("IsModelFileExists TypeCloudBrainOne objectName=%s", objectName)
  21. isExist, err := storage.IsObjectExist4Minio(setting.Attachment.Minio.Bucket, objectName)
  22. if err != nil {
  23. return false
  24. }
  25. return isExist
  26. }
  27. return false
  28. }