diff options
author | zeripath <art27@cantab.net> | 2021-11-23 03:09:35 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-22 22:09:35 -0500 |
commit | 188fd2dd1a778ad140a569b31d2bf6c95e2a6bae (patch) | |
tree | 9e10531fbeaf7df945b0d10e3ffce620d3d6d696 /services/cron | |
parent | 9450410ff71db5c6076fbe72e4b47fc9798b8d14 (diff) | |
download | gitea-188fd2dd1a778ad140a569b31d2bf6c95e2a6bae.tar.gz gitea-188fd2dd1a778ad140a569b31d2bf6c95e2a6bae.zip |
Add `PULL_LIMIT` and `PUSH_LIMIT` to cron.update_mirror task (#17568)
Diffstat (limited to 'services/cron')
-rw-r--r-- | services/cron/tasks_basic.go | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/services/cron/tasks_basic.go b/services/cron/tasks_basic.go index 57fb399d4e..219173ccf0 100644 --- a/services/cron/tasks_basic.go +++ b/services/cron/tasks_basic.go @@ -18,13 +18,24 @@ import ( ) func registerUpdateMirrorTask() { - RegisterTaskFatal("update_mirrors", &BaseConfig{ - Enabled: true, - RunAtStart: false, - Schedule: "@every 10m", - NoSuccessNotice: true, - }, func(ctx context.Context, _ *models.User, _ Config) error { - return mirror_service.Update(ctx) + type UpdateMirrorTaskConfig struct { + BaseConfig + PullLimit int + PushLimit int + } + + RegisterTaskFatal("update_mirrors", &UpdateMirrorTaskConfig{ + BaseConfig: BaseConfig{ + Enabled: true, + RunAtStart: false, + Schedule: "@every 10m", + NoSuccessNotice: true, + }, + PullLimit: 50, + PushLimit: 50, + }, func(ctx context.Context, _ *models.User, cfg Config) error { + umtc := cfg.(*UpdateMirrorTaskConfig) + return mirror_service.Update(ctx, umtc.PullLimit, umtc.PushLimit) }) } |