Browse Source

fix bug when migrate repository 500 when repo is existed (#6188)

* fix bug when migrate repository 500 when repo is existed

* use 409 but not 422 for error status code when not exist

* translation fix
for-closed-social
Lunny Xiao 5 years ago
committed by techknowlogick
parent
commit
7afe81f28e
2 changed files with 10 additions and 0 deletions
  1. +5
    -0
      routers/api/v1/repo/repo.go
  2. +5
    -0
      routers/repo/repo.go

+ 5
- 0
routers/api/v1/repo/repo.go View File

@ -408,6 +408,11 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
RemoteAddr: remoteAddr,
})
if err != nil {
if models.IsErrRepoAlreadyExist(err) {
ctx.Error(409, "", "The repository with the same name already exists.")
return
}
err = util.URLSanitizedError(err, remoteAddr)
if repo != nil {
if errDelete := models.DeleteRepository(ctx.User, ctxUser.ID, repo.ID); errDelete != nil {

+ 5
- 0
routers/repo/repo.go View File

@ -256,6 +256,11 @@ func MigratePost(ctx *context.Context, form auth.MigrateRepoForm) {
return
}
if models.IsErrRepoAlreadyExist(err) {
ctx.RenderWithErr(ctx.Tr("form.repo_name_been_taken"), tplMigrate, &form)
return
}
// remoteAddr may contain credentials, so we sanitize it
err = util.URLSanitizedError(err, remoteAddr)

Loading…
Cancel
Save