diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-04-29 02:14:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-28 14:14:26 -0400 |
commit | a6450494c3a9c05667ae8a2ebdfdea55b8206e9b (patch) | |
tree | e4c6eba554eb4866337f82f2f96521b4b9370f84 /routers | |
parent | 572af214a7256fde76d0fa69fc5791b1758455ef (diff) | |
download | gitea-a6450494c3a9c05667ae8a2ebdfdea55b8206e9b.tar.gz gitea-a6450494c3a9c05667ae8a2ebdfdea55b8206e9b.zip |
Fix unclear `IsRepositoryExist` logic (#24374)
There was only one `IsRepositoryExist` function, it did: `has && isDir`
However it's not right, and it would cause 500 error when creating a new
repository if the dir exists.
Then, it was changed to `has || isDir`, it is still incorrect, it
affects the "adopt repo" logic.
To make the logic clear:
* IsRepositoryModelOrDirExist
* IsRepositoryModelExist
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/admin/adopt.go | 4 | ||||
-rw-r--r-- | routers/web/admin/repos.go | 2 | ||||
-rw-r--r-- | routers/web/user/setting/adopt.go | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/routers/api/v1/admin/adopt.go b/routers/api/v1/admin/adopt.go index 47fd0ef3c3..ccd8be9171 100644 --- a/routers/api/v1/admin/adopt.go +++ b/routers/api/v1/admin/adopt.go @@ -95,7 +95,7 @@ func AdoptRepository(ctx *context.APIContext) { } // check not a repo - has, err := repo_model.IsRepositoryExist(ctx, ctxUser, repoName) + has, err := repo_model.IsRepositoryModelExist(ctx, ctxUser, repoName) if err != nil { ctx.InternalServerError(err) return @@ -157,7 +157,7 @@ func DeleteUnadoptedRepository(ctx *context.APIContext) { } // check not a repo - has, err := repo_model.IsRepositoryExist(ctx, ctxUser, repoName) + has, err := repo_model.IsRepositoryModelExist(ctx, ctxUser, repoName) if err != nil { ctx.InternalServerError(err) return diff --git a/routers/web/admin/repos.go b/routers/web/admin/repos.go index b22546f749..9a0e467b48 100644 --- a/routers/web/admin/repos.go +++ b/routers/web/admin/repos.go @@ -133,7 +133,7 @@ func AdoptOrDeleteRepository(ctx *context.Context) { repoName := dirSplit[1] // check not a repo - has, err := repo_model.IsRepositoryExist(ctx, ctxUser, repoName) + has, err := repo_model.IsRepositoryModelExist(ctx, ctxUser, repoName) if err != nil { ctx.ServerError("IsRepositoryExist", err) return diff --git a/routers/web/user/setting/adopt.go b/routers/web/user/setting/adopt.go index c9995e7278..01668c3954 100644 --- a/routers/web/user/setting/adopt.go +++ b/routers/web/user/setting/adopt.go @@ -31,7 +31,7 @@ func AdoptOrDeleteRepository(ctx *context.Context) { root := user_model.UserPath(ctxUser.LowerName) // check not a repo - has, err := repo_model.IsRepositoryExist(ctx, ctxUser, dir) + has, err := repo_model.IsRepositoryModelExist(ctx, ctxUser, dir) if err != nil { ctx.ServerError("IsRepositoryExist", err) return |