diff --git a/models/repo/pushmirror.go b/models/repo/pushmirror.go index 24c58faf8..bf134abfb 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 9a06bb095..3bf8aa384 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 8d7669762..cb1803f7c 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 e721b7c73..fc1403b3c 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 8456bb409..07b2f58d5 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -79,206 +79,212 @@ {{ctx.Locale.Tr "repo.settings.mirror_settings"}}
- {{if $newMirrorsEntirelyEnabled}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs"}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}

- {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.pull_mirror_instructions"}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_pull_section"}}
- {{else if $onlyNewPushMirrorsEnabled}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_pull_mirror.instructions"}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.more_information_if_disabled"}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}
- {{else if $onlyNewPullMirrorsEnabled}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.instructions"}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.pull_mirror_warning"}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.more_information_if_disabled"}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}

- {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.info"}} - {{if $existingPushMirror}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.can_still_use"}} - {{end}} + {{if .Repository.IsArchived}} +
+ {{ctx.Locale.Tr "repo.settings.archive.mirrors_unavailable"}} +
{{else}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.no_new_mirrors"}} {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.can_still_use"}}
- {{end}} - - {{if $existingPushMirror}} - - - - - - - - + {{if $newMirrorsEntirelyEnabled}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs"}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}

+ {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.pull_mirror_instructions"}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_pull_section"}}
+ {{else if $onlyNewPushMirrorsEnabled}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_pull_mirror.instructions"}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.more_information_if_disabled"}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}
+ {{else if $onlyNewPullMirrorsEnabled}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.instructions"}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.pull_mirror_warning"}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.more_information_if_disabled"}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}

+ {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.info"}} + {{if $existingPushMirror}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.can_still_use"}} + {{end}} + {{else}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.no_new_mirrors"}} {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.can_still_use"}}
{{end}} - {{if $modifyBrokenPullMirror}} - {{/* even if a repo is a pull mirror (IsMirror=true), the PullMirror might still be nil if the mirror migration is broken */}} +
{{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"}}
+ {{if $existingPushMirror}} + + + + + + + + + {{end}} + {{if $modifyBrokenPullMirror}} + {{/* even if a repo is a pull mirror (IsMirror=true), the PullMirror might still be nil if the mirror migration is broken */}} + + + + + + {{else if $isWorkingPullMirror}} - + + + - - {{else if $isWorkingPullMirror}} - - - - - - - - - - - - - {{end}}{{/* end if: IsMirror */}} - - {{range .PushMirrors}} - - - - - - - {{else}} - - - - {{end}} - {{if (not .DisableNewPushMirrors)}} - {{end}} - -
{{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}} +
+ {{.CsrfTokenHtml}} + + +
{{.PullMirror.RemoteAddress}}{{ctx.Locale.Tr "repo.settings.mirror_settings.direction.pull"}}{{DateTime "full" .PullMirror.UpdatedUnix}} -
- {{.CsrfTokenHtml}} - - -
-
-
- {{template "base/disable_form_autofill"}} - {{.CsrfTokenHtml}} - -
- -
- - -
-
-
- - -
- {{$address := MirrorRemoteAddress $.Context .Repository .PullMirror.GetRemoteName false}} -
- - -

{{ctx.Locale.Tr "repo.mirror_address_desc"}}

-
-
- - {{ctx.Locale.Tr "repo.need_auth"}} - -
-
- - -
-
- - -
-

{{ctx.Locale.Tr "repo.mirror_password_help"}}

-
-
- - {{if .LFSStartServer}} -
- -
- - -
-
-
- - -

{{ctx.Locale.Tr "repo.mirror_lfs_endpoint_desc" "https://github.com/git-lfs/git-lfs/blob/main/docs/api/server-discovery.md#server-discovery" | Str2html}}

-
- {{end}} -
- -
-
-
{{.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}}
- -
- {{$.CsrfTokenHtml}} - - - -
-
- {{$.CsrfTokenHtml}} - - - -
-
{{ctx.Locale.Tr "repo.settings.mirror_settings.push_mirror.none"}}
{{template "base/disable_form_autofill"}} {{.CsrfTokenHtml}} - -
- - + +
+ +
+ + +
+
+
+ + +
+ {{$address := MirrorRemoteAddress $.Context .Repository .PullMirror.GetRemoteName false}} +
+ +

{{ctx.Locale.Tr "repo.mirror_address_desc"}}

-
+
{{ctx.Locale.Tr "repo.need_auth"}}
-
- - +
+ +
-
- - +
+ +
+

{{ctx.Locale.Tr "repo.mirror_password_help"}}

-
+ + {{if .LFSStartServer}} +
+
- - + +
-
- - +
+ + +

{{ctx.Locale.Tr "repo.mirror_lfs_endpoint_desc" "https://github.com/git-lfs/git-lfs/blob/main/docs/api/server-discovery.md#server-discovery" | Str2html}}

+ {{end}}
- +
+ + + {{end}}{{/* end if: IsMirror */}} + + {{range .PushMirrors}} + + {{.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}} + + +
+ {{$.CsrfTokenHtml}} + + + +
+
+ {{$.CsrfTokenHtml}} + + + +
+ + + {{else}} + + {{ctx.Locale.Tr "repo.settings.mirror_settings.push_mirror.none"}} + + {{end}} + {{if (not .DisableNewPushMirrors)}} + + +
+ {{template "base/disable_form_autofill"}} + {{.CsrfTokenHtml}} + +
+ + +

{{ctx.Locale.Tr "repo.mirror_address_desc"}}

+
+
+ + {{ctx.Locale.Tr "repo.need_auth"}} + +
+
+ + +
+
+ + +
+
+
+
+
+ + +
+
+
+ + +
+
+ +
+
+ + + {{end}} + + + {{end}}
{{end}}