From aac63a44048ea004e65e6d0540e4722a0cdbafbd Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Tue, 15 Jan 2013 15:55:51 +0400 Subject: [PATCH] #823: small refactoring --- lib/abf_worker/publish_observer.rb | 4 +--- lib/tasks/new_core.rake | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/lib/abf_worker/publish_observer.rb b/lib/abf_worker/publish_observer.rb index c3f9d1653..b7a03e708 100644 --- a/lib/abf_worker/publish_observer.rb +++ b/lib/abf_worker/publish_observer.rb @@ -10,9 +10,7 @@ module AbfWorker case status when COMPLETED bl.published - when FAILED - bl.fail_publish - when CANCELED + when FAILED, CANCELED bl.fail_publish end AbfWorker::BuildListsPublishTaskManager.unlock_build_list bl diff --git a/lib/tasks/new_core.rake b/lib/tasks/new_core.rake index 98d384e90..a571e1f05 100644 --- a/lib/tasks/new_core.rake +++ b/lib/tasks/new_core.rake @@ -69,24 +69,24 @@ namespace :new_core do order(:id). find_in_batches(:batch_size => 100) do | build_lists | - build_lists.each do | bl | - puts "[#{Time.zone.now}] - where build_lists.id #{bl.id}" + build_lists.each do | bl | + puts "[#{Time.zone.now}] - where build_lists.id #{bl.id}" - sha1 = (bl.results.find{ |r| r['file_name'] =~ /.*\.tar\.gz$/ } || {})['sha1'] - next unless sha1 - dir = Dir.mktmpdir('update-packages-', "#{APP_CONFIG['root_path']}") - begin - system "cd #{dir} && curl -L -O #{APP_CONFIG['file_store_url']}/api/v1/file_stores/#{sha1}; tar -xzf #{sha1}" - system "rm -f #{dir}/#{sha1}" + sha1 = (bl.results.find{ |r| r['file_name'] =~ /.*\.tar\.gz$/ } || {})['sha1'] + next unless sha1 + dir = Dir.mktmpdir('update-packages-', "#{APP_CONFIG['root_path']}") + begin + system "cd #{dir} && curl -L -O #{APP_CONFIG['file_store_url']}/api/v1/file_stores/#{sha1}; tar -xzf #{sha1}" + system "rm -f #{dir}/#{sha1}" - extract_rpms_and_update_packages("#{dir}/archives/SRC_RPM", bl, 'source', token) - extract_rpms_and_update_packages("#{dir}/archives/RPM", bl, 'binary', token) - ensure - # remove the directory. - FileUtils.remove_entry_secure dir + extract_rpms_and_update_packages("#{dir}/archives/SRC_RPM", bl, 'source', token) + extract_rpms_and_update_packages("#{dir}/archives/RPM", bl, 'binary', token) + ensure + # remove the directory. + FileUtils.remove_entry_secure dir + end end - end # build_lists.each - end # find_in_batches + end say "[#{Time.zone.now}] done" end