aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-05-18 00:07:41 +0800
committerGitHub <noreply@github.com>2024-05-17 16:07:41 +0000
commit821d2fc2a3cc897f21d707455850177077b72410 (patch)
tree4ef79b19770147b16897bb7c66da3deb8a08a4b0 /routers/api
parent68d5c18953620927101609bbd21508213cbcd589 (diff)
downloadgitea-821d2fc2a3cc897f21d707455850177077b72410.tar.gz
gitea-821d2fc2a3cc897f21d707455850177077b72410.zip
Simplify mirror repository API logic (#30963)
Fix #30921
Diffstat (limited to 'routers/api')
-rw-r--r--routers/api/v1/repo/repo.go12
1 files changed, 3 insertions, 9 deletions
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index 7f35a7fe41..e759142938 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -1062,16 +1062,10 @@ func updateRepoArchivedState(ctx *context.APIContext, opts api.EditRepoOption) e
func updateMirror(ctx *context.APIContext, opts api.EditRepoOption) error {
repo := ctx.Repo.Repository
- // only update mirror if interval or enable prune are provided
- if opts.MirrorInterval == nil && opts.EnablePrune == nil {
- return nil
- }
-
- // these values only make sense if the repo is a mirror
+ // Skip this update if the repo is not a mirror, do not return error.
+ // Because reporting errors only makes the logic more complex&fragile, it doesn't really help end users.
if !repo.IsMirror {
- err := fmt.Errorf("repo is not a mirror, can not change mirror interval")
- ctx.Error(http.StatusUnprocessableEntity, err.Error(), err)
- return err
+ return nil
}
// get the mirror from the repo