Fork to maintain patches against the official gitea for https://code.ceondo.com https://github.com/go-gitea/gitea

v37.go 728B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package migrations
  5. import (
  6. "html"
  7. "code.gitea.io/gitea/models"
  8. "github.com/go-xorm/xorm"
  9. )
  10. func unescapeUserFullNames(x *xorm.Engine) (err error) {
  11. const batchSize = 100
  12. for start := 0; ; start += batchSize {
  13. users := make([]*models.User, 0, batchSize)
  14. if err := x.Limit(start, batchSize).Find(users); err != nil {
  15. return err
  16. }
  17. if len(users) == 0 {
  18. return nil
  19. }
  20. for _, user := range users {
  21. user.FullName = html.UnescapeString(user.FullName)
  22. if _, err := x.Cols("full_name").Update(user); err != nil {
  23. return err
  24. }
  25. }
  26. }
  27. }