aboutsummaryrefslogtreecommitdiffstats
path: root/routers/repo/setting.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/repo/setting.go')
-rw-r--r--routers/repo/setting.go51
1 files changed, 31 insertions, 20 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index 33ed5b8aae..80b44ad220 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -104,34 +104,42 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
}
}
- if repo.IsMirror {
- if isNameChanged {
- var err error
- ctx.Repo.Mirror, err = models.GetMirror(repo.ID)
- if err != nil {
- ctx.Handle(500, "RefreshRepositoryMirror", err)
- return
- }
- }
+ ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success"))
+ ctx.Redirect(repo.Link() + "/settings")
- if form.Interval > 0 {
- ctx.Repo.Mirror.EnablePrune = form.EnablePrune
- ctx.Repo.Mirror.Interval = form.Interval
- ctx.Repo.Mirror.NextUpdate = time.Now().Add(time.Duration(form.Interval) * time.Hour)
- if err := models.UpdateMirror(ctx.Repo.Mirror); err != nil {
- ctx.Handle(500, "UpdateMirror", err)
- return
- }
- }
- if err := ctx.Repo.Mirror.SaveAddress(form.MirrorAddress); err != nil {
- ctx.Handle(500, "SaveAddress", err)
+ case "mirror":
+ if !repo.IsMirror {
+ ctx.Handle(404, "", nil)
+ return
+ }
+
+ if form.Interval > 0 {
+ ctx.Repo.Mirror.EnablePrune = form.EnablePrune
+ ctx.Repo.Mirror.Interval = form.Interval
+ ctx.Repo.Mirror.NextUpdate = time.Now().Add(time.Duration(form.Interval) * time.Hour)
+ if err := models.UpdateMirror(ctx.Repo.Mirror); err != nil {
+ ctx.Handle(500, "UpdateMirror", err)
return
}
}
+ if err := ctx.Repo.Mirror.SaveAddress(form.MirrorAddress); err != nil {
+ ctx.Handle(500, "SaveAddress", err)
+ return
+ }
ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success"))
ctx.Redirect(repo.Link() + "/settings")
+ case "mirror-sync":
+ if !repo.IsMirror {
+ ctx.Handle(404, "", nil)
+ return
+ }
+
+ go models.MirrorQueue.Add(repo.ID)
+ ctx.Flash.Info(ctx.Tr("repo.settings.mirror_sync_in_progress"))
+ ctx.Redirect(repo.Link() + "/settings")
+
case "advanced":
repo.EnableWiki = form.EnableWiki
repo.EnableExternalWiki = form.EnableExternalWiki
@@ -278,6 +286,9 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
ctx.Flash.Success(ctx.Tr("repo.settings.wiki_deletion_success"))
ctx.Redirect(ctx.Repo.RepoLink + "/settings")
+
+ default:
+ ctx.Handle(404, "", nil)
}
}