From 7afe81f28e530c1c5aed1583654b3d772c368fa5 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 26 Feb 2019 22:28:56 +0800 Subject: 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 --- routers/api/v1/repo/repo.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'routers/api') diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 4156775286..c6a7803acb 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -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 { -- cgit v1.2.3