Skip to content

Commit a31f64d

Browse files
appleboylunny
authored andcommitted
fix: 500 error on /explore/repos page. (#946)
1 parent 9d2b830 commit a31f64d

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

models/repo.go

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,10 +1198,8 @@ func Repositories(opts *SearchRepoOptions) (_ RepositoryList, err error) {
11981198
return nil, fmt.Errorf("Repo: %v", err)
11991199
}
12001200

1201-
if opts.Searcher != nil || opts.Starred {
1202-
if err = repos.loadAttributes(x); err != nil {
1203-
return nil, fmt.Errorf("LoadAttributes: %v", err)
1204-
}
1201+
if err = repos.loadAttributes(x); err != nil {
1202+
return nil, fmt.Errorf("LoadAttributes: %v", err)
12051203
}
12061204

12071205
return repos, nil
@@ -1743,10 +1741,8 @@ func GetRecentUpdatedRepositories(opts *SearchRepoOptions) (repos RepositoryList
17431741
return nil, fmt.Errorf("Repo: %v", err)
17441742
}
17451743

1746-
if opts.Searcher != nil || opts.Starred {
1747-
if err = repos.loadAttributes(x); err != nil {
1748-
return nil, fmt.Errorf("LoadAttributes: %v", err)
1749-
}
1744+
if err = repos.loadAttributes(x); err != nil {
1745+
return nil, fmt.Errorf("LoadAttributes: %v", err)
17501746
}
17511747

17521748
return repos, nil
@@ -1781,14 +1777,15 @@ func GetPrivateRepositoryCount(u *User) (int64, error) {
17811777

17821778
// SearchRepoOptions holds the search options
17831779
type SearchRepoOptions struct {
1784-
Keyword string
1785-
OwnerID int64
1786-
Searcher *User //ID of the person who's seeking
1787-
OrderBy string
1788-
Private bool // Include private repositories in results
1789-
Starred bool
1790-
Page int
1791-
PageSize int // Can be smaller than or equal to setting.ExplorePagingNum
1780+
Keyword string
1781+
OwnerID int64
1782+
Searcher *User //ID of the person who's seeking
1783+
OrderBy string
1784+
Private bool // Include private repositories in results
1785+
Starred bool
1786+
Page int
1787+
IsProfile bool
1788+
PageSize int // Can be smaller than or equal to setting.ExplorePagingNum
17921789
}
17931790

17941791
// SearchRepositoryByName takes keyword and part of repository name to search,
@@ -1856,7 +1853,7 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (repos RepositoryList, _ in
18561853
return nil, 0, fmt.Errorf("Repo: %v", err)
18571854
}
18581855

1859-
if opts.Searcher != nil || opts.Starred {
1856+
if !opts.IsProfile {
18601857
if err = repos.loadAttributes(x); err != nil {
18611858
return nil, 0, fmt.Errorf("LoadAttributes: %v", err)
18621859
}

routers/user/profile.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,13 @@ func Profile(ctx *context.Context) {
192192
ctx.Data["Total"] = total
193193
} else {
194194
repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{
195-
Keyword: keyword,
196-
OwnerID: ctxUser.ID,
197-
OrderBy: orderBy,
198-
Private: showPrivate,
199-
Page: page,
200-
PageSize: setting.UI.User.RepoPagingNum,
195+
Keyword: keyword,
196+
OwnerID: ctxUser.ID,
197+
OrderBy: orderBy,
198+
Private: showPrivate,
199+
Page: page,
200+
IsProfile: true,
201+
PageSize: setting.UI.User.RepoPagingNum,
201202
})
202203
if err != nil {
203204
ctx.Handle(500, "SearchRepositoryByName", err)

0 commit comments

Comments
 (0)