An attempt to sync a non-mirror repo must give 400 (Bad Request) (#19300)
* An attempt to sync a non-mirror repo must give 400 (Bad Request) * add missing return statement Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
4f27c28947
commit
43ff92e122
2 changed files with 32 additions and 0 deletions
|
@ -5,8 +5,10 @@
|
|||
package repo
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
@ -48,6 +50,15 @@ func MirrorSync(ctx *context.APIContext) {
|
|||
return
|
||||
}
|
||||
|
||||
if _, err := repo_model.GetMirrorByRepoID(repo.ID); err != nil {
|
||||
if errors.Is(err, repo_model.ErrMirrorNotExist) {
|
||||
ctx.Error(http.StatusBadRequest, "MirrorSync", "Repository is not a mirror")
|
||||
return
|
||||
}
|
||||
ctx.Error(http.StatusInternalServerError, "MirrorSync", err)
|
||||
return
|
||||
}
|
||||
|
||||
mirror_service.StartToMirror(repo.ID)
|
||||
|
||||
ctx.Status(http.StatusOK)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue