mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
#2018 able to sync now for mirrors
- Refactor code to use sync.UniqueQueue - Closes #3509
This commit is contained in:
@@ -75,6 +75,7 @@ func GlobalInit() {
|
||||
|
||||
// Booting long running goroutines.
|
||||
cron.NewContext()
|
||||
models.InitSyncMirrors()
|
||||
models.InitDeliverHooks()
|
||||
models.InitTestPullRequests()
|
||||
log.NewGitLogger(path.Join(setting.LogRootPath, "http.log"))
|
||||
|
@@ -490,7 +490,6 @@ func UploadIssueAttachment(ctx *context.Context) {
|
||||
|
||||
func ViewIssue(ctx *context.Context) {
|
||||
ctx.Data["RequireHighlightJS"] = true
|
||||
ctx.Data["RequireSimpleMDE"] = true
|
||||
ctx.Data["RequireDropzone"] = true
|
||||
renderAttachmentSettings(ctx)
|
||||
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user