From 2b04d0bcf94c923f6face80f9310acfb048baedd Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 29 Jul 2013 19:35:16 +0400 Subject: [PATCH] abf/abf-ideas#83: updated AbfWorker::BuildListsPublishTaskManager --- app/models/repository.rb | 5 +++++ lib/abf_worker/build_lists_publish_task_manager.rb | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/app/models/repository.rb b/app/models/repository.rb index 9a52e9524..3b981ac2f 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -75,6 +75,11 @@ class Repository < ActiveRecord::Base lock_file_actions :remove, :repo end + # Presence of `.repo.lock` file means that mirror is currently synchronising the repository state. + def repo_lock_file_exists? + lock_file_actions :check, :repo + end + def add_member(member, role = 'admin') Relation.add_member(member, self, role) end diff --git a/lib/abf_worker/build_lists_publish_task_manager.rb b/lib/abf_worker/build_lists_publish_task_manager.rb index 79449636f..d6eb11df0 100644 --- a/lib/abf_worker/build_lists_publish_task_manager.rb +++ b/lib/abf_worker/build_lists_publish_task_manager.rb @@ -173,6 +173,8 @@ module AbfWorker resign_repos = @redis.lrange RESIGN_REPOSITORIES, 0, -1 Repository.where(:id => (resign_repos - locked_repositories)).each do |r| + # Checks mirror sync status + next if r.repo_lock_file_exists? @redis.lrem RESIGN_REPOSITORIES, 0, r.id @redis.lpush LOCKED_REPOSITORIES, r.id @@ -274,6 +276,9 @@ module AbfWorker return false if !bl && old_packages[:sources].empty? save_to_repository = Repository.find save_to_repository_id + # Checks mirror sync status + return false if save_to_repository.repo_lock_file_exists? + save_to_platform = save_to_repository.platform build_for_platform = Platform.find build_for_platform_id platform_path = "#{save_to_platform.path}/repository" @@ -346,6 +351,8 @@ module AbfWorker regen_repos = regen_repos_and_pl.map{ |r| r.gsub(/\-[\d]*$/, '') } Repository.where(:id => regen_repos).each do |rep| + # Checks mirror sync status + next if rep.repo_lock_file_exists? regen_repos_and_pl.select{ |kind| kind =~ /^#{rep.id}\-/ }.each do |lock_str| next if locked_rep_and_pl.include?(lock_str) @redis.lrem REGENERATE_METADATA, 0, lock_str