1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Fix repo avatar conflict (#32958)

Continue even if the avatar deleting fails
This commit is contained in:
wxiaoguang
2024-12-23 10:52:25 +08:00
committed by GitHub
parent b5f9a2d7c0
commit 462ce31530
4 changed files with 14 additions and 10 deletions

View File

@@ -8,7 +8,6 @@ import (
"fmt"
"io"
"strconv"
"strings"
"code.gitea.io/gitea/models/db"
repo_model "code.gitea.io/gitea/models/repo"
@@ -107,7 +106,8 @@ func RemoveRandomAvatars(ctx context.Context) error {
// generateAvatar generates the avatar from a template repository
func generateAvatar(ctx context.Context, templateRepo, generateRepo *repo_model.Repository) error {
generateRepo.Avatar = strings.Replace(templateRepo.Avatar, strconv.FormatInt(templateRepo.ID, 10), strconv.FormatInt(generateRepo.ID, 10), 1)
// generate a new different hash, whatever the "hash data" is, it doesn't matter
generateRepo.Avatar = avatar.HashAvatar(generateRepo.ID, []byte("new-avatar"))
if _, err := storage.Copy(storage.RepoAvatars, generateRepo.CustomAvatarRelativePath(), storage.RepoAvatars, templateRepo.CustomAvatarRelativePath()); err != nil {
return err
}