From 42d3985143cd1fade3b945f3ed3fb1cc991e58e8 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 11 Feb 2013 19:53:02 +0400 Subject: [PATCH] #913: fix for finding build_lists_for_cleanup --- .../build_lists_publish_task_manager.rb | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/abf_worker/build_lists_publish_task_manager.rb b/lib/abf_worker/build_lists_publish_task_manager.rb index 3149bc75e..eeb22822b 100644 --- a/lib/abf_worker/build_lists_publish_task_manager.rb +++ b/lib/abf_worker/build_lists_publish_task_manager.rb @@ -193,19 +193,25 @@ module AbfWorker projects_for_cleanup = @redis.lrange(PROJECTS_FOR_CLEANUP, 0, -1). select{ |k| k =~ /#{save_to_repository_id}\-#{build_for_platform_id}$/ } - build_lists_for_cleanup = projects_for_cleanup.map do |key| + build_lists_for_cleanup = [] + projects_for_cleanup.each do |key| pr, rep, pl = *key.split('-') - bl = BuildList.where(:project_id => pr). - where(:new_core => true, :status => BuildList::BUILD_PUBLISHED). - where(:save_to_repository_id => save_to_repository_id). - where(:build_for_platform_id => build_for_platform_id). - order(:updated_at).first - unless bl - # No packages for removing - @redis.lrem PROJECTS_FOR_CLEANUP, 0, key + added = false + Arch.pluck(:id).each do |arch_id| + bl = BuildList.where(:project_id => pr). + where(:new_core => true, :status => BuildList::BUILD_PUBLISHED). + where(:save_to_repository_id => save_to_repository_id). + where(:build_for_platform_id => build_for_platform_id). + where(:arch_id => arch_id). + order(:updated_at).first + if bl + build_lists_for_cleanup << bl + added = true + end end - bl - end.compact + # No packages for removing + @redis.lrem(PROJECTS_FOR_CLEANUP, 0, key) unless added + end bl = build_lists.first || build_lists_for_cleanup.first return false unless bl