mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 20:02:09 +00:00
#2018 able to sync now for mirrors
- Refactor code to use sync.UniqueQueue - Closes #3509
This commit is contained in:
parent
c1ecb6c60a
commit
8516dfcb6c
16 changed files with 345 additions and 242 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue