Make the step to change priority of repo bigger, so bad repos would be put behind faster.
Signed-off-by: Li Yuanchao lyc163mail@163.com --- lib/git_mirror.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/git_mirror.rb b/lib/git_mirror.rb index b543f02..60a4b76 100644 --- a/lib/git_mirror.rb +++ b/lib/git_mirror.rb @@ -481,7 +481,7 @@ end
# main thread class MirrorMain - WEEK_SECONDS = 604800 + MONTH_SECONDS = 2592000
def handle_feedback_new_refs(git_repo, feedback_info) return reload_fork_info(git_repo) if upstream_repo?(git_repo) @@ -584,18 +584,18 @@ class MirrorMain mirror_dir = "/srv/git/#{@git_info[git_repo]['belong']}/#{git_repo}" mirror_dir = "#{mirror_dir}.git" unless @git_info[git_repo]['is_submodule']
- return old_pri + Math.cbrt(WEEK_SECONDS) unless File.directory?(mirror_dir) + return old_pri + Math.cbrt(MONTH_SECONDS) unless File.directory?(mirror_dir)
return cal_priority(mirror_dir, old_pri) end
def cal_priority(mirror_dir, old_pri) last_commit_time = %x(git -C #{mirror_dir} log --pretty=format:"%ct" -1 2>/dev/null).to_i - return old_pri + Math.cbrt(WEEK_SECONDS) if last_commit_time.zero? + return old_pri + Math.cbrt(MONTH_SECONDS) if last_commit_time.zero?
t = Time.now.to_i interval = t - last_commit_time - return old_pri + Math.cbrt(WEEK_SECONDS) if interval <= 0 + return old_pri + Math.cbrt(MONTH_SECONDS) if interval <= 0
return old_pri + Math.cbrt(interval) end
On Wed, Apr 07, 2021 at 04:10:10PM +0800, Li Yuanchao wrote:
Make the step to change priority of repo bigger, so bad repos would be put behind faster.
Signed-off-by: Li Yuanchao lyc163mail@163.com
lib/git_mirror.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/git_mirror.rb b/lib/git_mirror.rb index b543f02..60a4b76 100644 --- a/lib/git_mirror.rb +++ b/lib/git_mirror.rb @@ -481,7 +481,7 @@ end
# main thread class MirrorMain
- WEEK_SECONDS = 604800
- MONTH_SECONDS = 2592000
MONTH_SECONDS => STEP_SECONDS then you just set the STEP_SECONDS and no need change it where you use it.
Thanks, Xueliang
def handle_feedback_new_refs(git_repo, feedback_info) return reload_fork_info(git_repo) if upstream_repo?(git_repo) @@ -584,18 +584,18 @@ class MirrorMain mirror_dir = "/srv/git/#{@git_info[git_repo]['belong']}/#{git_repo}" mirror_dir = "#{mirror_dir}.git" unless @git_info[git_repo]['is_submodule']
- return old_pri + Math.cbrt(WEEK_SECONDS) unless File.directory?(mirror_dir)
return old_pri + Math.cbrt(MONTH_SECONDS) unless File.directory?(mirror_dir)
return cal_priority(mirror_dir, old_pri) end
def cal_priority(mirror_dir, old_pri) last_commit_time = %x(git -C #{mirror_dir} log --pretty=format:"%ct" -1 2>/dev/null).to_i
- return old_pri + Math.cbrt(WEEK_SECONDS) if last_commit_time.zero?
return old_pri + Math.cbrt(MONTH_SECONDS) if last_commit_time.zero?
t = Time.now.to_i interval = t - last_commit_time
- return old_pri + Math.cbrt(WEEK_SECONDS) if interval <= 0
return old_pri + Math.cbrt(MONTH_SECONDS) if interval <= 0
return old_pri + Math.cbrt(interval) end
-- 2.23.0
On Wed, Apr 07, 2021 at 04:43:21PM +0800, Cao Xueliang wrote:
On Wed, Apr 07, 2021 at 04:10:10PM +0800, Li Yuanchao wrote:
Make the step to change priority of repo bigger, so bad repos would be put behind faster.
Signed-off-by: Li Yuanchao lyc163mail@163.com
lib/git_mirror.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/git_mirror.rb b/lib/git_mirror.rb index b543f02..60a4b76 100644 --- a/lib/git_mirror.rb +++ b/lib/git_mirror.rb @@ -481,7 +481,7 @@ end
# main thread class MirrorMain
- WEEK_SECONDS = 604800
- MONTH_SECONDS = 2592000
MONTH_SECONDS => STEP_SECONDS then you just set the STEP_SECONDS and no need change it where you use it.
ok
Thanks, Yuanchao