mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 10:20:39 +00:00
Use context for RepositoryList.LoadAttributes
(#23435)
This commit is contained in:
parent
cdc9e91750
commit
d74a7efb60
3 changed files with 5 additions and 9 deletions
|
@ -62,7 +62,8 @@ func RepositoryListOfMap(repoMap map[int64]*Repository) RepositoryList {
|
||||||
return RepositoryList(ValuesRepository(repoMap))
|
return RepositoryList(ValuesRepository(repoMap))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repos RepositoryList) loadAttributes(ctx context.Context) error {
|
// LoadAttributes loads the attributes for the given RepositoryList
|
||||||
|
func (repos RepositoryList) LoadAttributes(ctx context.Context) error {
|
||||||
if len(repos) == 0 {
|
if len(repos) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -107,11 +108,6 @@ func (repos RepositoryList) loadAttributes(ctx context.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadAttributes loads the attributes for the given RepositoryList
|
|
||||||
func (repos RepositoryList) LoadAttributes() error {
|
|
||||||
return repos.loadAttributes(db.DefaultContext)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SearchRepoOptions holds the search options
|
// SearchRepoOptions holds the search options
|
||||||
type SearchRepoOptions struct {
|
type SearchRepoOptions struct {
|
||||||
db.ListOptions
|
db.ListOptions
|
||||||
|
@ -547,7 +543,7 @@ func SearchRepositoryByCondition(ctx context.Context, opts *SearchRepoOptions, c
|
||||||
}
|
}
|
||||||
|
|
||||||
if loadAttributes {
|
if loadAttributes {
|
||||||
if err := repos.loadAttributes(ctx); err != nil {
|
if err := repos.LoadAttributes(ctx); err != nil {
|
||||||
return nil, 0, fmt.Errorf("LoadAttributes: %w", err)
|
return nil, 0, fmt.Errorf("LoadAttributes: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ func listUserRepos(ctx *context.APIContext, u *user_model.User, private bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repos.LoadAttributes(); err != nil {
|
if err := repos.LoadAttributes(ctx); err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, "RepositoryList.LoadAttributes", err)
|
ctx.Error(http.StatusInternalServerError, "RepositoryList.LoadAttributes", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ func getNotifications(ctx *context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
notifications = notifications.Without(failures)
|
notifications = notifications.Without(failures)
|
||||||
if err := repos.LoadAttributes(); err != nil { // TODO
|
if err := repos.LoadAttributes(ctx); err != nil {
|
||||||
ctx.ServerError("LoadAttributes", err)
|
ctx.ServerError("LoadAttributes", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue