#167: allow regenerate metadata for personal platforms
This commit is contained in:
parent
ba2b49f233
commit
97465fd106
|
@ -141,7 +141,8 @@ class Platforms::RepositoriesController < Platforms::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def regenerate_metadata
|
def regenerate_metadata
|
||||||
if AbfWorker::BuildListsPublishTaskManager.repository_regenerate_metadata @repository.id
|
build_for_platform = Platform.main.find params[:build_for_platform_id] if @repository.platform.personal?
|
||||||
|
if AbfWorker::BuildListsPublishTaskManager.repository_regenerate_metadata @repository, (build_for_platform || @repository.platform)
|
||||||
flash[:notice] = t('flash.repository.regenerate_in_queue')
|
flash[:notice] = t('flash.repository.regenerate_in_queue')
|
||||||
else
|
else
|
||||||
flash[:error] = t('flash.repository.regenerate_already_in_queue')
|
flash[:error] = t('flash.repository.regenerate_already_in_queue')
|
||||||
|
|
|
@ -10,13 +10,6 @@
|
||||||
.both
|
.both
|
||||||
|
|
||||||
.hr
|
.hr
|
||||||
- if ['edit', 'update'].include?(controller.action_name) && can?(:regenerate_metadata, @repository)
|
|
||||||
.leftside= t('layout.repositories.regenerate_metadata')
|
|
||||||
.rightside
|
|
||||||
= link_to t('layout.repositories.regenerate_metadata').split.first, regenerate_metadata_platform_repository_path(@platform, @repository),
|
|
||||||
:method => :put, :confirm => t('layout.confirm'), :class => :button
|
|
||||||
.hr{:style => 'padding-bottom:20px;'}
|
|
||||||
.both
|
|
||||||
|
|
||||||
.button_block
|
.button_block
|
||||||
= submit_tag t("layout.save")
|
= submit_tag t("layout.save")
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
.hr
|
||||||
|
= form_for @repository, :url => regenerate_metadata_platform_repository_path(@platform, @repository), :html => { :class => :form, :method => :put } do |f|
|
||||||
|
.leftside= t('layout.repositories.regenerate_metadata')
|
||||||
|
.rightside
|
||||||
|
= select_tag :build_for_platform_id, options_from_collection_for_select(Platform.main, :id, :name) if @platform.personal?
|
||||||
|
= f.submit t('layout.repositories.regenerate_metadata'), :confirm => t('layout.confirm')
|
||||||
|
.hr{:style => 'padding-bottom:20px;'}
|
||||||
|
.both
|
|
@ -8,6 +8,8 @@
|
||||||
= render "form", :f => f
|
= render "form", :f => f
|
||||||
%br
|
%br
|
||||||
|
|
||||||
|
= render 'regenerate_metadata' if can?(:regenerate_metadata, @repository)
|
||||||
|
|
||||||
- if @platform.main?
|
- if @platform.main?
|
||||||
= render "shared/members_table",
|
= render "shared/members_table",
|
||||||
:remove_members_path => remove_members_platform_repository_path(@platform, @repository),
|
:remove_members_path => remove_members_platform_repository_path(@platform, @repository),
|
||||||
|
|
|
@ -57,9 +57,10 @@ module AbfWorker
|
||||||
redis.lpush RESIGN_REPOSITORIES, key_pair.repository_id
|
redis.lpush RESIGN_REPOSITORIES, key_pair.repository_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def repository_regenerate_metadata(repository_id)
|
def repository_regenerate_metadata(repository, build_for_platform)
|
||||||
return false if Resque.redis.lrange(REGENERATE_METADATA, 0, -1).include? repository_id.to_s
|
key = "#{repository.id}-#{build_for_platform.id}"
|
||||||
redis.lpush REGENERATE_METADATA, repository_id
|
return false if Resque.redis.lrange(REGENERATE_METADATA, 0, -1).include? key
|
||||||
|
redis.lpush REGENERATE_METADATA, key
|
||||||
end
|
end
|
||||||
|
|
||||||
def unlock_repository(repository_id)
|
def unlock_repository(repository_id)
|
||||||
|
@ -337,50 +338,50 @@ module AbfWorker
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
# Only for main platforms!
|
|
||||||
def create_tasks_for_repository_regenerate_metadata
|
def create_tasks_for_repository_regenerate_metadata
|
||||||
worker_queue = 'publish_worker_default'
|
worker_queue = 'publish_worker_default'
|
||||||
worker_class = 'AbfWorker::PublishWorkerDefault'
|
worker_class = 'AbfWorker::PublishWorkerDefault'
|
||||||
regen_repos = @redis.lrange REGENERATE_METADATA, 0, -1
|
regen_repos_and_pl = @redis.lrange REGENERATE_METADATA, 0, -1
|
||||||
locked_rep_and_pl = @redis.lrange(LOCKED_REP_AND_PLATFORMS, 0, -1)
|
locked_rep_and_pl = @redis.lrange(LOCKED_REP_AND_PLATFORMS, 0, -1)
|
||||||
|
|
||||||
|
regen_repos = regen_repos_and_pl.map{ |r| r.gsub(/\-[\d]*$/, '') }
|
||||||
Repository.where(:id => regen_repos).each do |rep|
|
Repository.where(:id => regen_repos).each do |rep|
|
||||||
lock_str = "#{rep.id}-#{rep.platform_id}"
|
regen_repos_and_pl.select{ |kind| kind =~ /^#{rep.id}\-/ }.each do |lock_str|
|
||||||
next if locked_rep_and_pl.include?("#{rep.id}-#{rep.platform_id}")
|
next if locked_rep_and_pl.include?(lock_str)
|
||||||
@redis.lrem REGENERATE_METADATA, 0, rep.id
|
@redis.lrem REGENERATE_METADATA, 0, lock_str
|
||||||
|
|
||||||
platform_path = "#{rep.platform.path}/repository"
|
build_for_platform = Platform.find lock_str.gsub(/^[\d]*\-/, '')
|
||||||
distrib_type = rep.platform.distrib_type
|
cmd_params = {
|
||||||
cmd_params = {
|
'RELEASED' => rep.platform.released,
|
||||||
'RELEASED' => rep.platform.released,
|
'REPOSITORY_NAME' => rep.name,
|
||||||
'REPOSITORY_NAME' => rep.name,
|
'TYPE' => build_for_platform.distrib_type,
|
||||||
'TYPE' => distrib_type,
|
'REGENERATE_METADATA' => true,
|
||||||
'REGENERATE_METADATA' => true,
|
'SAVE_TO_PLATFORM' => rep.platform.name,
|
||||||
'SAVE_TO_PLATFORM' => rep.platform.name,
|
'BUILD_FOR_PLATFORM' => build_for_platform.name
|
||||||
'BUILD_FOR_PLATFORM' => rep.platform.name
|
}.map{ |k, v| "#{k}=#{v}" }.join(' ')
|
||||||
}.map{ |k, v| "#{k}=#{v}" }.join(' ')
|
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
:id => Time.now.to_i,
|
:id => Time.now.to_i,
|
||||||
:arch => 'x86_64',
|
:arch => 'x86_64',
|
||||||
:distrib_type => distrib_type,
|
:distrib_type => build_for_platform.distrib_type,
|
||||||
:cmd_params => cmd_params,
|
:cmd_params => cmd_params,
|
||||||
:platform => {:platform_path => platform_path},
|
:platform => {:platform_path => "#{rep.platform.path}/repository"},
|
||||||
:repository => {:id => rep.id},
|
:repository => {:id => rep.id},
|
||||||
:type => :publish,
|
:type => :publish,
|
||||||
:time_living => 9600, # 160 min
|
:time_living => 9600, # 160 min
|
||||||
:skip_feedback => true,
|
:skip_feedback => true,
|
||||||
:extra => {:lock_str => lock_str, :regenerate => true}
|
:extra => {:lock_str => lock_str, :regenerate => true}
|
||||||
}
|
}
|
||||||
|
|
||||||
Resque.push(
|
Resque.push(
|
||||||
worker_queue,
|
worker_queue,
|
||||||
'class' => worker_class,
|
'class' => worker_class,
|
||||||
'args' => [options.merge({
|
'args' => [options.merge({
|
||||||
})]
|
})]
|
||||||
)
|
)
|
||||||
|
|
||||||
@redis.lpush(LOCKED_REP_AND_PLATFORMS, lock_str)
|
@redis.lpush(LOCKED_REP_AND_PLATFORMS, lock_str)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue