diff options
author | Unknwon <u@gogs.io> | 2015-03-12 15:09:40 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-03-12 15:09:40 -0400 |
commit | 6b70a0c0d926fd128063ab387820cee31890e556 (patch) | |
tree | eaba5379ea9196b39833ff14fb11e91d3fb577fd /models/migrations | |
parent | 4aafeace230a35e80fb443739c2642d23fc93e51 (diff) | |
download | gitea-6b70a0c0d926fd128063ab387820cee31890e556.tar.gz gitea-6b70a0c0d926fd128063ab387820cee31890e556.zip |
#1032: legacy code can have duplicated IDs for same repository
Diffstat (limited to 'models/migrations')
-rw-r--r-- | models/migrations/migrations.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 8d2d5b40a1..4b5f5a6975 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -341,12 +341,15 @@ func teamToTeamRepo(x *xorm.Engine) error { orgID := com.StrTo(team["org_id"]).MustInt64() teamID := com.StrTo(team["id"]).MustInt64() + // #1032: legacy code can have duplicated IDs for same repository. + mark := make(map[int64]bool) for _, idStr := range strings.Split(string(team["repo_ids"]), "|") { repoID := com.StrTo(strings.TrimPrefix(idStr, "$")).MustInt64() - if repoID == 0 { + if repoID == 0 || mark[repoID] { continue } + mark[repoID] = true teamRepos = append(teamRepos, &TeamRepo{ OrgID: orgID, TeamID: teamID, |