aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-10-01 21:40:17 +0800
committerGitHub <noreply@github.com>2019-10-01 21:40:17 +0800
commit7ff783b7320bdeda89ed6a021c304e64f9d9170e (patch)
treeaba54e41a83ec4064f0d5d09024e94c4ce4030d1 /routers
parent177aedfca9bf4a15dd154a1f1ac136e9ba3e0f24 (diff)
downloadgitea-7ff783b7320bdeda89ed6a021c304e64f9d9170e.tar.gz
gitea-7ff783b7320bdeda89ed6a021c304e64f9d9170e.zip
Move mirror to a standalone package from models (#7486)
* move mirror to a standalone package * fix mirror address in template * fix tests * fix lint * fix comment * fix tests * fix tests * fix vendor * fix fmt * fix lint * remove wrong file submitted * fix conflict * remove unrelated changes * fix go mod * fix tests * clean go mod * make vendor work * make vendor work * fix tests * remove duplicated test
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/repo.go4
-rw-r--r--routers/init.go3
-rw-r--r--routers/repo/setting.go6
3 files changed, 9 insertions, 4 deletions
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index c838ba7271..513e7a37b3 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -20,6 +20,7 @@ import (
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/routers/api/v1/convert"
+ mirror_service "code.gitea.io/gitea/services/mirror"
)
var searchOrderByMap = map[string]map[string]models.SearchOrderBy{
@@ -869,6 +870,7 @@ func MirrorSync(ctx *context.APIContext) {
ctx.Error(403, "MirrorSync", "Must have write access")
}
- go models.MirrorQueue.Add(repo.ID)
+ mirror_service.StartToMirror(repo.ID)
+
ctx.Status(200)
}
diff --git a/routers/init.go b/routers/init.go
index 5c8741f244..1efddcfaa6 100644
--- a/routers/init.go
+++ b/routers/init.go
@@ -21,6 +21,7 @@ import (
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/ssh"
"code.gitea.io/gitea/services/mailer"
+ mirror_service "code.gitea.io/gitea/services/mirror"
"gitea.com/macaron/macaron"
)
@@ -98,7 +99,7 @@ func GlobalInit() {
log.Fatal("Failed to initialize issue indexer: %v", err)
}
models.InitRepoIndexer()
- models.InitSyncMirrors()
+ mirror_service.InitSyncMirrors()
models.InitDeliverHooks()
models.InitTestPullRequests()
}
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index b0af396e7d..c74b273420 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -25,6 +25,7 @@ import (
"code.gitea.io/gitea/modules/validation"
"code.gitea.io/gitea/routers/utils"
"code.gitea.io/gitea/services/mailer"
+ mirror_service "code.gitea.io/gitea/services/mirror"
"github.com/unknwon/com"
"mvdan.cc/xurls/v2"
@@ -190,7 +191,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
address = u.String()
- if err := ctx.Repo.Mirror.SaveAddress(address); err != nil {
+ if err := mirror_service.SaveAddress(ctx.Repo.Mirror, address); err != nil {
ctx.ServerError("SaveAddress", err)
return
}
@@ -204,7 +205,8 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
return
}
- go models.MirrorQueue.Add(repo.ID)
+ mirror_service.StartToMirror(repo.ID)
+
ctx.Flash.Info(ctx.Tr("repo.settings.mirror_sync_in_progress"))
ctx.Redirect(repo.Link() + "/settings")