aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClark Boylan <clark.boylan@gmail.com>2020-07-02 07:55:42 -0700
committerGitHub <noreply@github.com>2020-07-02 15:55:42 +0100
commit7e401fb026db85205f19f008e9dbb24ab05f20db (patch)
tree11267ba876d7a29539290700f3c54388e19dd17b
parent482ba937ed118d68448c5fe347ee7e43f5621c0b (diff)
downloadgitea-7e401fb026db85205f19f008e9dbb24ab05f20db.tar.gz
gitea-7e401fb026db85205f19f008e9dbb24ab05f20db.zip
Fix repo API listing stability (#12057)
Repo listings are paginated in the API now. Unfortunately, they are ORDER BY updated_unix which only has second resolution. This means that if you do a listing when multiple projects were created at the same time you can unstable ordering. If that unstable ordering happens at a page boundary you may fail to get a complete repo listing. To make things worse sorting by updated_unix means that we may never get a complete listing because udpated_unix can change independent of our API calls. Fix this by making the API repo listing order by id instead.
-rw-r--r--routers/api/v1/user/repo.go1
1 files changed, 1 insertions, 0 deletions
diff --git a/routers/api/v1/user/repo.go b/routers/api/v1/user/repo.go
index 519a999a98..dbd18f133d 100644
--- a/routers/api/v1/user/repo.go
+++ b/routers/api/v1/user/repo.go
@@ -22,6 +22,7 @@ func listUserRepos(ctx *context.APIContext, u *models.User, private bool) {
Actor: u,
Private: private,
ListOptions: opts,
+ OrderBy: "id ASC",
})
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetUserRepositories", err)