diff --git a/models/repo/pushmirror.go b/models/repo/pushmirror.go index 24c58faf849b2..bf134abfb152a 100644 --- a/models/repo/pushmirror.go +++ b/models/repo/pushmirror.go @@ -121,8 +121,11 @@ func GetPushMirrorsSyncedOnCommit(ctx context.Context, repoID int64) ([]*PushMir // PushMirrorsIterate iterates all push-mirror repositories. func PushMirrorsIterate(ctx context.Context, limit int, f func(idx int, bean any) error) error { sess := db.GetEngine(ctx). - Where("last_update + (`interval` / ?) <= ?", time.Second, time.Now().Unix()). - And("`interval` != 0"). + Table("push_mirror"). + Join("INNER", "`repository`", "`repository`.id = `push_mirror`.repo_id"). + Where("`push_mirror`.last_update + (`push_mirror`.`interval` / ?) <= ?", time.Second, time.Now().Unix()). + And("`push_mirror`.`interval` != 0"). + And("`repository`.is_archived = ?", false). OrderBy("last_update ASC") if limit > 0 { sess = sess.Limit(limit) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 9a06bb0952d80..3bf8aa3845009 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2377,6 +2377,7 @@ settings.archive.error = An error occurred while trying to archive the repo. See settings.archive.error_ismirror = You cannot archive a mirrored repo. settings.archive.branchsettings_unavailable = Branch settings are not available if the repo is archived. settings.archive.tagsettings_unavailable = Tag settings are not available if the repo is archived. +settings.archive.mirrors_unavailable = Mirrors are not available if the repo is archived. settings.unarchive.button = Unarchive repo settings.unarchive.header = Unarchive this repo settings.unarchive.text = Unarchiving the repo will restore its ability to receive commits and pushes, as well as new issues and pull-requests. diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 8d7669762b722..cb1803f7c652f 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -1181,13 +1181,13 @@ func Routes() *web.Route { Delete(reqToken(), reqRepoWriter(unit.TypeReleases), repo.DeleteReleaseByTag) }) }, reqRepoReader(unit.TypeReleases)) - m.Post("/mirror-sync", reqToken(), reqRepoWriter(unit.TypeCode), repo.MirrorSync) - m.Post("/push_mirrors-sync", reqAdmin(), reqToken(), repo.PushMirrorSync) + m.Post("/mirror-sync", reqToken(), reqRepoWriter(unit.TypeCode), mustNotBeArchived, repo.MirrorSync) + m.Post("/push_mirrors-sync", reqAdmin(), reqToken(), mustNotBeArchived, repo.PushMirrorSync) m.Group("/push_mirrors", func() { m.Combo("").Get(repo.ListPushMirrors). - Post(bind(api.CreatePushMirrorOption{}), repo.AddPushMirror) + Post(mustNotBeArchived, bind(api.CreatePushMirrorOption{}), repo.AddPushMirror) m.Combo("/{name}"). - Delete(repo.DeletePushMirrorByRemoteName). + Delete(mustNotBeArchived, repo.DeletePushMirrorByRemoteName). Get(repo.GetPushMirrorByName) }, reqAdmin(), reqToken()) diff --git a/routers/web/repo/setting/setting.go b/routers/web/repo/setting/setting.go index e721b7c739972..fc1403b3cc0b0 100644 --- a/routers/web/repo/setting/setting.go +++ b/routers/web/repo/setting/setting.go @@ -185,7 +185,7 @@ func SettingsPost(ctx *context.Context) { ctx.Redirect(repo.Link() + "/settings") case "mirror": - if !setting.Mirror.Enabled || !repo.IsMirror { + if !setting.Mirror.Enabled || !repo.IsMirror || repo.IsArchived { ctx.NotFound("", nil) return } @@ -278,7 +278,7 @@ func SettingsPost(ctx *context.Context) { ctx.Redirect(repo.Link() + "/settings") case "mirror-sync": - if !setting.Mirror.Enabled || !repo.IsMirror { + if !setting.Mirror.Enabled || !repo.IsMirror || repo.IsArchived { ctx.NotFound("", nil) return } @@ -306,7 +306,7 @@ func SettingsPost(ctx *context.Context) { ctx.Redirect(repo.Link() + "/settings") case "push-mirror-update": - if !setting.Mirror.Enabled { + if !setting.Mirror.Enabled || repo.IsArchived { ctx.NotFound("", nil) return } @@ -343,7 +343,7 @@ func SettingsPost(ctx *context.Context) { ctx.Redirect(repo.Link() + "/settings") case "push-mirror-remove": - if !setting.Mirror.Enabled { + if !setting.Mirror.Enabled || repo.IsArchived { ctx.NotFound("", nil) return } @@ -372,7 +372,7 @@ func SettingsPost(ctx *context.Context) { ctx.Redirect(repo.Link() + "/settings") case "push-mirror-add": - if setting.Mirror.DisableNewPush { + if setting.Mirror.DisableNewPush || repo.IsArchived { ctx.NotFound("", nil) return } diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index 8456bb409b358..07b2f58d53bff 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -79,206 +79,212 @@ {{ctx.Locale.Tr "repo.settings.mirror_settings"}}
{{ctx.Locale.Tr "repo.settings.mirror_settings.mirrored_repository"}} | -{{ctx.Locale.Tr "repo.settings.mirror_settings.direction"}} | -{{ctx.Locale.Tr "repo.settings.mirror_settings.last_update"}} | -- |
---|
{{ctx.Locale.Tr "repo.settings.mirror_settings.mirrored_repository"}} | +{{ctx.Locale.Tr "repo.settings.mirror_settings.direction"}} | +{{ctx.Locale.Tr "repo.settings.mirror_settings.last_update"}} | ++ | ||||
---|---|---|---|---|---|---|---|
+ {{ctx.Locale.Tr "repo.settings.mirror_settings.direction.pull"}}: {{ctx.Locale.Tr "error.occurred"}}
+ |
+ |||||||
- {{ctx.Locale.Tr "repo.settings.mirror_settings.direction.pull"}}: {{ctx.Locale.Tr "error.occurred"}}
+ | {{.PullMirror.RemoteAddress}} | +{{ctx.Locale.Tr "repo.settings.mirror_settings.direction.pull"}} | +{{DateTime "full" .PullMirror.UpdatedUnix}} | ++ | |||
{{.PullMirror.RemoteAddress}} | -{{ctx.Locale.Tr "repo.settings.mirror_settings.direction.pull"}} | -{{DateTime "full" .PullMirror.UpdatedUnix}} | -- - | -||||
- - | -|||||||
{{.RemoteAddress}} | -{{ctx.Locale.Tr "repo.settings.mirror_settings.direction.push"}} | -{{if .LastUpdateUnix}}{{DateTime "full" .LastUpdateUnix}}{{else}}{{ctx.Locale.Tr "never"}}{{end}} {{if .LastError}} {{ctx.Locale.Tr "error"}} {{end}} |
- - - - - | -||||
{{ctx.Locale.Tr "repo.settings.mirror_settings.push_mirror.none"}} | -|||||||