#960: update #unlock_rep_and_platform method

This commit is contained in:
Vokhmin Alexey V 2013-03-01 16:25:58 +04:00
parent eb7492dafd
commit 4287bdca4a
3 changed files with 11 additions and 15 deletions

View File

@ -22,7 +22,7 @@ module AbfWorker
protected
def subject
@subject ||= @subject_class.where(:id => options['id']).first
@subject ||= @subject_class.find options['id']
end
def update_results

View File

@ -65,8 +65,8 @@ module AbfWorker
redis.lrem LOCKED_BUILD_LISTS, 0, build_list.id
end
def unlock_rep_and_platform(build_list, str = nil)
redis.lrem LOCKED_REP_AND_PLATFORMS, 0, str || "#{build_list.save_to_repository_id}-#{build_list.build_for_platform_id}"
def unlock_rep_and_platform(lock_str)
redis.lrem LOCKED_REP_AND_PLATFORMS, 0, lock_str
end
def redis
@ -238,6 +238,7 @@ module AbfWorker
'TYPE' => distrib_type
}.map{ |k, v| "#{k}=#{v}" }.join(' ')
lock_str = "#{save_to_repository_id}-#{build_for_platform_id}"
options = {
:id => bl.id,
:arch => bl.arch.name,
@ -246,7 +247,8 @@ module AbfWorker
:platform => {:platform_path => platform_path},
:repository => {:id => bl.save_to_repository.id},
:type => :publish,
:time_living => 9600 # 160 min
:time_living => 9600, # 160 min
:extra => {:lock_str => lock_str}
}
packages = {:sources => [], :binaries => {:x86_64 => [], :i586 => []}}
@ -288,7 +290,7 @@ module AbfWorker
@redis.lpush LOCKED_PROJECTS_FOR_CLEANUP, key
end
@redis.lpush(LOCKED_REP_AND_PLATFORMS, "#{save_to_repository_id}-#{build_for_platform_id}")
@redis.lpush(LOCKED_REP_AND_PLATFORMS, lock_str)
return true
end

View File

@ -13,7 +13,7 @@ module AbfWorker
AbfWorker::BuildListsPublishTaskManager.unlock_repository options['id']
else
if options['extra']['regenerate'] # Regenerate metadata
AbfWorker::BuildListsPublishTaskManager.unlock_rep_and_platform nil, options['extra']['lock_str']
AbfWorker::BuildListsPublishTaskManager.unlock_rep_and_platform options['extra']['lock_str']
elsif options['extra']['create_container'] # Container has been created
case status
when COMPLETED
@ -50,13 +50,7 @@ module AbfWorker
AbfWorker::BuildListsPublishTaskManager.cleanup_failed options['projects_for_cleanup']
end
bl = build_lists.first || subject
# unlock repository when main build list does not exist
if !bl && options['projects_for_cleanup'].present?
pr, rep, pl = options['projects_for_cleanup'][0].split('-')
bl = BuildList.where(:build_for_platform_id => pl, :save_to_repository_id => rep).first
end
AbfWorker::BuildListsPublishTaskManager.unlock_rep_and_platform bl
AbfWorker::BuildListsPublishTaskManager.unlock_rep_and_platform options['extra']['lock_str']
end
def update_results(build_list = subject)