Skip to content

Commit d74a7ef

Browse files
authored
Use context for RepositoryList.LoadAttributes (#23435)
1 parent cdc9e91 commit d74a7ef

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

models/repo/repo_list.go

+3-7
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ func RepositoryListOfMap(repoMap map[int64]*Repository) RepositoryList {
6262
return RepositoryList(ValuesRepository(repoMap))
6363
}
6464

65-
func (repos RepositoryList) loadAttributes(ctx context.Context) error {
65+
// LoadAttributes loads the attributes for the given RepositoryList
66+
func (repos RepositoryList) LoadAttributes(ctx context.Context) error {
6667
if len(repos) == 0 {
6768
return nil
6869
}
@@ -107,11 +108,6 @@ func (repos RepositoryList) loadAttributes(ctx context.Context) error {
107108
return nil
108109
}
109110

110-
// LoadAttributes loads the attributes for the given RepositoryList
111-
func (repos RepositoryList) LoadAttributes() error {
112-
return repos.loadAttributes(db.DefaultContext)
113-
}
114-
115111
// SearchRepoOptions holds the search options
116112
type SearchRepoOptions struct {
117113
db.ListOptions
@@ -547,7 +543,7 @@ func SearchRepositoryByCondition(ctx context.Context, opts *SearchRepoOptions, c
547543
}
548544

549545
if loadAttributes {
550-
if err := repos.loadAttributes(ctx); err != nil {
546+
if err := repos.LoadAttributes(ctx); err != nil {
551547
return nil, 0, fmt.Errorf("LoadAttributes: %w", err)
552548
}
553549
}

routers/api/v1/user/repo.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func listUserRepos(ctx *context.APIContext, u *user_model.User, private bool) {
3131
return
3232
}
3333

34-
if err := repos.LoadAttributes(); err != nil {
34+
if err := repos.LoadAttributes(ctx); err != nil {
3535
ctx.Error(http.StatusInternalServerError, "RepositoryList.LoadAttributes", err)
3636
return
3737
}

routers/web/user/notification.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func getNotifications(ctx *context.Context) {
117117
return
118118
}
119119
notifications = notifications.Without(failures)
120-
if err := repos.LoadAttributes(); err != nil { // TODO
120+
if err := repos.LoadAttributes(ctx); err != nil {
121121
ctx.ServerError("LoadAttributes", err)
122122
return
123123
}

0 commit comments

Comments
 (0)