From 1a44b634f9e644ac97a5fc34765e040572cb390e Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 20 Mar 2013 01:11:16 +0400 Subject: [PATCH] Update BuildListsPublishTaskManager and PublishObserver --- lib/abf_worker/base_observer.rb | 2 +- lib/abf_worker/build_lists_publish_task_manager.rb | 3 ++- lib/abf_worker/publish_observer.rb | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/abf_worker/base_observer.rb b/lib/abf_worker/base_observer.rb index 45151da79..d7d1ec01a 100644 --- a/lib/abf_worker/base_observer.rb +++ b/lib/abf_worker/base_observer.rb @@ -32,7 +32,7 @@ module AbfWorker def sort_results_and_save(results, item = subject) item.results = results.sort_by{ |r| r['file_name'] } - item.save! + item.save(false) end end diff --git a/lib/abf_worker/build_lists_publish_task_manager.rb b/lib/abf_worker/build_lists_publish_task_manager.rb index dc731f2dc..4ec75ea8a 100644 --- a/lib/abf_worker/build_lists_publish_task_manager.rb +++ b/lib/abf_worker/build_lists_publish_task_manager.rb @@ -237,8 +237,9 @@ module AbfWorker build_lists = build_lists.where('build_lists.id NOT IN (?)', locked_ids) unless locked_ids.empty? build_lists = build_lists.limit(50) + project_ids = build_lists.map(&:project_id).uniq projects_for_cleanup = @redis.lrange(PROJECTS_FOR_CLEANUP, 0, -1). - select{ |k| k =~ /#{save_to_repository_id}\-#{build_for_platform_id}$/ } + select{ |k| k =~ /#{save_to_repository_id}\-#{build_for_platform_id}$/ && k !~ /^(#{project_ids.join('|')})\-/ } old_packages = {:sources => [], :binaries => {:x86_64 => [], :i586 => []}} diff --git a/lib/abf_worker/publish_observer.rb b/lib/abf_worker/publish_observer.rb index a3958510f..c4acc9204 100644 --- a/lib/abf_worker/publish_observer.rb +++ b/lib/abf_worker/publish_observer.rb @@ -36,9 +36,10 @@ module AbfWorker update_results build_list case status when COMPLETED - build_list.published + # `update_column` - when build_list has been removed from repository + build_list.published || build_list.update_column(:status, BuildList::BUILD_PUBLISHED) when FAILED, CANCELED - build_list.fail_publish + build_list.fail_publish || build_list.update_column(:status, BuildList::FAILED_PUBLISH) end AbfWorker::BuildListsPublishTaskManager.unlock_build_list build_list end