From ac6954780576d9066976d62f992b1a07b4018b32 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 11 Feb 2013 21:12:58 +0600 Subject: [PATCH 01/10] [refs #893] add regenerate metadata for repository --- .../platforms/repositories_controller.rb | 4 ++ app/models/ability.rb | 4 +- app/models/repository.rb | 1 - .../platforms/repositories/_form.html.haml | 3 + config/locales/models/repository.en.yml | 1 + config/locales/models/repository.ru.yml | 1 + config/routes.rb | 1 + .../build_lists_publish_task_manager.rb | 55 ++++++++++++++++++- lib/abf_worker/publish_observer.rb | 7 ++- 9 files changed, 70 insertions(+), 7 deletions(-) diff --git a/app/controllers/platforms/repositories_controller.rb b/app/controllers/platforms/repositories_controller.rb index 4c936a039..655477593 100644 --- a/app/controllers/platforms/repositories_controller.rb +++ b/app/controllers/platforms/repositories_controller.rb @@ -140,6 +140,10 @@ class Platforms::RepositoriesController < Platforms::BaseController redirect_to platform_repository_path(@platform, @repository), :notice => t('flash.repository.project_removed') end + def regenerate_metadata + AbfWorker::BuildListsPublishTaskManager.repository_regenerate_metadata @repository + end + protected def set_members diff --git a/app/models/ability.rb b/app/models/ability.rb index b517f0d3f..14a5bd7b7 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -103,7 +103,7 @@ class Ability can [:read, :projects_list, :projects], Repository, :platform => {:owner_type => 'User', :owner_id => user.id} can [:read, :projects_list, :projects], Repository, :platform => {:owner_type => 'Group', :owner_id => user.group_ids} can([:read, :projects_list, :projects], Repository, read_relations_for('repositories', 'platforms')) {|repository| local_reader? repository.platform} - can([:create, :edit, :update, :destroy, :projects_list, :projects, :add_project, :remove_project], Repository) {|repository| local_admin? repository.platform} + can([:create, :edit, :update, :destroy, :projects_list, :projects, :add_project, :remove_project, :regenerate_metadata], Repository) {|repository| local_admin? repository.platform} can([:remove_members, :remove_member, :add_member, :signatures], Repository) {|repository| owner?(repository.platform) || local_admin?(repository.platform)} can([:add_project, :remove_project], Repository) {|repository| repository.members.exists?(:id => user.id)} can(:clear, Platform) {|platform| local_admin?(platform) && platform.personal?} @@ -159,6 +159,8 @@ class Ability cannot([:get_list, :create], MassBuild) {|mass_build| mass_build.platform.personal?} cannot(:cancel, MassBuild) {|mass_build| mass_build.platform.personal? || mass_build.stop_build} + cannot(:regenerate_metadata, Repository) {|repository| !repository.platform.main?} + if @user.system? can :key_pair, Repository else diff --git a/app/models/repository.rb b/app/models/repository.rb index 5dc03a4a5..7abee60a5 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -2,7 +2,6 @@ class Repository < ActiveRecord::Base belongs_to :platform - has_many :relations, :as => :target, :dependent => :destroy has_many :actors, :as => :target, :class_name => 'Relation', :dependent => :destroy has_many :members, :through => :actors, :source => :actor, :source_type => 'User' diff --git a/app/views/platforms/repositories/_form.html.haml b/app/views/platforms/repositories/_form.html.haml index 065e99e24..24abe4538 100644 --- a/app/views/platforms/repositories/_form.html.haml +++ b/app/views/platforms/repositories/_form.html.haml @@ -1,6 +1,9 @@ - unless ['edit', 'update'].include? controller.action_name .leftlist= f.label :name, t("activerecord.attributes.repository.name"), :class => :label .rightlist= f.text_field :name, :class => 'text_field' +- else + = link_to t("layout.repositories.regenerate_metadata"), regenerate_metadata_platform_repository_path(@platform, @repository), :method => :put, :confirm => t('layout.confirm') + %br .leftlist= f.label :description, t("activerecord.attributes.repository.description"), :class => :label .rightlist= f.text_field :description, :class => 'text_field' diff --git a/config/locales/models/repository.en.yml b/config/locales/models/repository.en.yml index 5fe13700d..3049627e2 100644 --- a/config/locales/models/repository.en.yml +++ b/config/locales/models/repository.en.yml @@ -18,6 +18,7 @@ en: clear: Clear clear_confirm: Are you sure you want to clear this platform? clear_warning: Attention! Cleared packages cannot be restored! + regenerate_metadata: Regenerate metadata personal_repositories: settings_header: Settings diff --git a/config/locales/models/repository.ru.yml b/config/locales/models/repository.ru.yml index a35396fd9..db0ade89e 100644 --- a/config/locales/models/repository.ru.yml +++ b/config/locales/models/repository.ru.yml @@ -18,6 +18,7 @@ ru: clear: Очистить clear_confirm: Уверены, что хотите очистить платформу? clear_warning: Внимание! Очищенные пакеты не могут быть восстановлены! + regenerate_metadata: Регенерировать метаданные personal_repositories: settings_header: Настройки diff --git a/config/routes.rb b/config/routes.rb index 4741438f4..e97aa16ce 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -151,6 +151,7 @@ Rosa::Application.routes.draw do post :remove_members # fixme: change post to delete delete :remove_member post :add_member + put :regenerate_metadata end end resources :key_pairs, :only => [:create, :index, :destroy] diff --git a/lib/abf_worker/build_lists_publish_task_manager.rb b/lib/abf_worker/build_lists_publish_task_manager.rb index 3149bc75e..e164a77cf 100644 --- a/lib/abf_worker/build_lists_publish_task_manager.rb +++ b/lib/abf_worker/build_lists_publish_task_manager.rb @@ -8,7 +8,8 @@ module AbfWorker LOCKED_PROJECTS_FOR_CLEANUP LOCKED_REPOSITORIES LOCKED_REP_AND_PLATFORMS - LOCKED_BUILD_LISTS).each do |kind| + LOCKED_BUILD_LISTS + REGENERATE_METADATA).each do |kind| const_set kind, "#{REDIS_MAIN_KEY}#{kind.downcase.gsub('_', '-')}" end @@ -20,6 +21,7 @@ module AbfWorker def run create_tasks_for_resign_repositories create_tasks_for_build_rpms + create_tasks_for_repository_regenerate_metadata end class << self @@ -50,6 +52,10 @@ module AbfWorker redis.lpush RESIGN_REPOSITORIES, key_pair.repository_id end + def repository_regenerate_metadata(repository_id) + redis.lpush REGENERATE_METADATA, repository_id + end + def unlock_repository(repository_id) redis.lrem LOCKED_REPOSITORIES, 0, repository_id end @@ -58,8 +64,8 @@ module AbfWorker redis.lrem LOCKED_BUILD_LISTS, 0, build_list.id end - def unlock_rep_and_platform(build_list) - redis.lrem LOCKED_REP_AND_PLATFORMS, 0, "#{build_list.save_to_repository_id}-#{build_list.build_for_platform_id}" + 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}" end def redis @@ -291,5 +297,48 @@ module AbfWorker end end + def create_tasks_for_repository_regenerate_metadata + worker_queue = 'publish_worker_default' + worker_class = 'AbfWorker::PublishWorkerDefault' + lock_str = "#{rep.id}-#{rep.platform_id}" + regen_repos = @redis.lrange REGENERATE_METADATA, 0, -1 + locked_rep_and_pl = @redis.lrange(LOCKED_REP_AND_PLATFORMS, 0, -1) + + Repository.where(:id => regen_repos).each do |rep| + next if locked_rep_and_pl.include?("#{rep.id}-#{rep.platform_id}") + @redis.lrem REGENERATE_METADATA, 0, rep.id + + platform_path = "#{rep.platform.path}/repository" + distrib_type = rep.platform.distrib_type + cmd_params = { + 'RELEASED' => rep.platform.released, + 'REPOSITORY_NAME' => rep.name, + 'TYPE' => distrib_type, + 'REGENERATE_METADATA' => true + }.map{ |k, v| "#{k}=#{v}" }.join(' ') + + options = { + :id => Time.now.to_i, + #:arch => nil, + :distrib_type => distrib_type, + :cmd_params => cmd_params, + :platform => {:platform_path => platform_path}, + :repository => {:id => rep.id}, + :type => :regenerate, + :time_living => 9600, # 160 min + :lock_str => lock_str + } + + Resque.push( + worker_queue, + 'class' => worker_class, + 'args' => [options.merge({ + })] + ) + + @redis.lpush(LOCKED_REP_AND_PLATFORMS, lock_str) + end + return true + end end end diff --git a/lib/abf_worker/publish_observer.rb b/lib/abf_worker/publish_observer.rb index a4bafb737..b3b72e010 100644 --- a/lib/abf_worker/publish_observer.rb +++ b/lib/abf_worker/publish_observer.rb @@ -9,8 +9,11 @@ module AbfWorker def perform return if status == STARTED # do nothing when publication started - if options['type'] == 'resign' - AbfWorker::BuildListsPublishTaskManager.unlock_repository options['id'] + case options['type'] + when 'resign' + AbfWorker::BuildListsPublishTaskManager.unlock_repository options['id'] + when 'regenerate' + AbfWorker::BuildListsPublishTaskManager.unlock_rep_and_platform nil, options['lock_str'] else if options['extra']['create_container'] # Container has been created case status From 9ff869f167562cc00c0fedb466eee75f0f2b60a5 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 11 Feb 2013 23:32:31 +0600 Subject: [PATCH 02/10] [refs #893] fix button && action --- app/controllers/platforms/repositories_controller.rb | 1 + app/views/platforms/repositories/_form.html.haml | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/platforms/repositories_controller.rb b/app/controllers/platforms/repositories_controller.rb index 655477593..0091967f5 100644 --- a/app/controllers/platforms/repositories_controller.rb +++ b/app/controllers/platforms/repositories_controller.rb @@ -142,6 +142,7 @@ class Platforms::RepositoriesController < Platforms::BaseController def regenerate_metadata AbfWorker::BuildListsPublishTaskManager.repository_regenerate_metadata @repository + redirect_to platform_repository_path(@platform, @repository) end protected diff --git a/app/views/platforms/repositories/_form.html.haml b/app/views/platforms/repositories/_form.html.haml index 24abe4538..4c8011ffb 100644 --- a/app/views/platforms/repositories/_form.html.haml +++ b/app/views/platforms/repositories/_form.html.haml @@ -2,8 +2,10 @@ .leftlist= f.label :name, t("activerecord.attributes.repository.name"), :class => :label .rightlist= f.text_field :name, :class => 'text_field' - else - = link_to t("layout.repositories.regenerate_metadata"), regenerate_metadata_platform_repository_path(@platform, @repository), :method => :put, :confirm => t('layout.confirm') - %br + .leftlist + .rightlist + = link_to t("layout.repositories.regenerate_metadata"), regenerate_metadata_platform_repository_path(@platform, @repository), + :method => :put, :confirm => t('layout.confirm'), :class => :button .leftlist= f.label :description, t("activerecord.attributes.repository.description"), :class => :label .rightlist= f.text_field :description, :class => 'text_field' From a4d1d42792c80ef47be63493cd14ad8bc9ecc7c5 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 11 Feb 2013 23:40:17 +0600 Subject: [PATCH 03/10] [refs #878] fix commit treeish --- app/models/project.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/project.rb b/app/models/project.rb index 264e77fe4..42b60419e 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -179,6 +179,7 @@ class Project < ActiveRecord::Base end def default_head treeish = nil # maybe need change 'head'? + return treeish if repo.commit(treeish).present? if repo.branches_and_tags.map(&:name).include?(treeish || default_branch) treeish || default_branch else From 677195b1164c187f5e728a92013bfc58d3e98514 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 12 Feb 2013 16:52:40 +0600 Subject: [PATCH 04/10] [refs #893] some fixes from comments --- app/controllers/platforms/repositories_controller.rb | 2 +- app/views/platforms/repositories/_form.html.haml | 5 +++-- lib/abf_worker/build_lists_publish_task_manager.rb | 7 ++++--- lib/abf_worker/publish_observer.rb | 9 ++++----- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/controllers/platforms/repositories_controller.rb b/app/controllers/platforms/repositories_controller.rb index 0091967f5..7e9d42ce4 100644 --- a/app/controllers/platforms/repositories_controller.rb +++ b/app/controllers/platforms/repositories_controller.rb @@ -141,7 +141,7 @@ class Platforms::RepositoriesController < Platforms::BaseController end def regenerate_metadata - AbfWorker::BuildListsPublishTaskManager.repository_regenerate_metadata @repository + AbfWorker::BuildListsPublishTaskManager.repository_regenerate_metadata @repository.id redirect_to platform_repository_path(@platform, @repository) end diff --git a/app/views/platforms/repositories/_form.html.haml b/app/views/platforms/repositories/_form.html.haml index 4c8011ffb..69c84c252 100644 --- a/app/views/platforms/repositories/_form.html.haml +++ b/app/views/platforms/repositories/_form.html.haml @@ -4,8 +4,9 @@ - else .leftlist .rightlist - = link_to t("layout.repositories.regenerate_metadata"), regenerate_metadata_platform_repository_path(@platform, @repository), - :method => :put, :confirm => t('layout.confirm'), :class => :button + -if can? :regenerate_metadata, @repository + = link_to t("layout.repositories.regenerate_metadata"), regenerate_metadata_platform_repository_path(@platform, @repository), + :method => :put, :confirm => t('layout.confirm'), :class => :button .leftlist= f.label :description, t("activerecord.attributes.repository.description"), :class => :label .rightlist= f.text_field :description, :class => 'text_field' diff --git a/lib/abf_worker/build_lists_publish_task_manager.rb b/lib/abf_worker/build_lists_publish_task_manager.rb index e164a77cf..5c549928d 100644 --- a/lib/abf_worker/build_lists_publish_task_manager.rb +++ b/lib/abf_worker/build_lists_publish_task_manager.rb @@ -319,14 +319,15 @@ module AbfWorker options = { :id => Time.now.to_i, - #:arch => nil, + :arch => 'x86_64', :distrib_type => distrib_type, :cmd_params => cmd_params, :platform => {:platform_path => platform_path}, :repository => {:id => rep.id}, - :type => :regenerate, + :type => :publish, :time_living => 9600, # 160 min - :lock_str => lock_str + :skip_feedback => true, + :extra => {:lock_str => lock_str, :regenerate => true} } Resque.push( diff --git a/lib/abf_worker/publish_observer.rb b/lib/abf_worker/publish_observer.rb index b3b72e010..e0cf779d9 100644 --- a/lib/abf_worker/publish_observer.rb +++ b/lib/abf_worker/publish_observer.rb @@ -9,13 +9,12 @@ module AbfWorker def perform return if status == STARTED # do nothing when publication started - case options['type'] - when 'resign' + if options['type'] == 'resign' AbfWorker::BuildListsPublishTaskManager.unlock_repository options['id'] - when 'regenerate' - AbfWorker::BuildListsPublishTaskManager.unlock_rep_and_platform nil, options['lock_str'] else - if options['extra']['create_container'] # Container has been created + if options['extra']['regenerate'] # Regenerate metadata + AbfWorker::BuildListsPublishTaskManager.unlock_rep_and_platform nil, options['lock_str'] + elsif options['extra']['create_container'] # Container has been created case status when COMPLETED subject.published_container From 2f86905e0213ace244ed3b1f8c7a1cd26ef47f52 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 12 Feb 2013 17:16:19 +0600 Subject: [PATCH 05/10] [refs #893] remove spaces --- lib/abf_worker/publish_observer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/abf_worker/publish_observer.rb b/lib/abf_worker/publish_observer.rb index e0cf779d9..67a46f3ed 100644 --- a/lib/abf_worker/publish_observer.rb +++ b/lib/abf_worker/publish_observer.rb @@ -10,7 +10,7 @@ module AbfWorker def perform return if status == STARTED # do nothing when publication started if options['type'] == 'resign' - AbfWorker::BuildListsPublishTaskManager.unlock_repository options['id'] + AbfWorker::BuildListsPublishTaskManager.unlock_repository options['id'] else if options['extra']['regenerate'] # Regenerate metadata AbfWorker::BuildListsPublishTaskManager.unlock_rep_and_platform nil, options['lock_str'] From ba68fa6043c8041534fae9f4684dedb7f5421854 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 12 Feb 2013 17:16:45 +0600 Subject: [PATCH 06/10] [refs #893] small refactoring --- app/views/platforms/repositories/_form.html.haml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/views/platforms/repositories/_form.html.haml b/app/views/platforms/repositories/_form.html.haml index 69c84c252..9cbc5ab3d 100644 --- a/app/views/platforms/repositories/_form.html.haml +++ b/app/views/platforms/repositories/_form.html.haml @@ -1,12 +1,11 @@ -- unless ['edit', 'update'].include? controller.action_name +- if ['edit', 'update'].exclude? controller.action_name .leftlist= f.label :name, t("activerecord.attributes.repository.name"), :class => :label .rightlist= f.text_field :name, :class => 'text_field' -- else +- elsif can? :regenerate_metadata, @repository .leftlist .rightlist - -if can? :regenerate_metadata, @repository - = link_to t("layout.repositories.regenerate_metadata"), regenerate_metadata_platform_repository_path(@platform, @repository), - :method => :put, :confirm => t('layout.confirm'), :class => :button + = link_to t("layout.repositories.regenerate_metadata"), regenerate_metadata_platform_repository_path(@platform, @repository), + :method => :put, :confirm => t('layout.confirm'), :class => :button .leftlist= f.label :description, t("activerecord.attributes.repository.description"), :class => :label .rightlist= f.text_field :description, :class => 'text_field' From 20baf2b2658d8ccfa50045a9f8228e0efa23b6a1 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 12 Feb 2013 19:11:07 +0600 Subject: [PATCH 07/10] [refs #893] fix error --- lib/abf_worker/publish_observer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/abf_worker/publish_observer.rb b/lib/abf_worker/publish_observer.rb index 67a46f3ed..96dfded56 100644 --- a/lib/abf_worker/publish_observer.rb +++ b/lib/abf_worker/publish_observer.rb @@ -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['lock_str'] + AbfWorker::BuildListsPublishTaskManager.unlock_rep_and_platform nil, options['extra']['lock_str'] elsif options['extra']['create_container'] # Container has been created case status when COMPLETED From 05b4d7366d04e9c95f15e1eca856e77e1f0534bf Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 12 Feb 2013 19:12:27 +0600 Subject: [PATCH 08/10] [refs #893] set higher priority to regenerate metadata --- lib/abf_worker/build_lists_publish_task_manager.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/abf_worker/build_lists_publish_task_manager.rb b/lib/abf_worker/build_lists_publish_task_manager.rb index 5c549928d..99750f1ba 100644 --- a/lib/abf_worker/build_lists_publish_task_manager.rb +++ b/lib/abf_worker/build_lists_publish_task_manager.rb @@ -20,8 +20,8 @@ module AbfWorker def run create_tasks_for_resign_repositories - create_tasks_for_build_rpms create_tasks_for_repository_regenerate_metadata + create_tasks_for_build_rpms end class << self From 9dfdfc5a04ea32ddb3127c9e8799bf07ae576be7 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 12 Feb 2013 19:30:28 +0600 Subject: [PATCH 09/10] [refs #893] add check & flash messages --- app/controllers/platforms/repositories_controller.rb | 7 ++++++- config/locales/models/repository.en.yml | 2 ++ config/locales/models/repository.ru.yml | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/controllers/platforms/repositories_controller.rb b/app/controllers/platforms/repositories_controller.rb index 7e9d42ce4..ea6c7293b 100644 --- a/app/controllers/platforms/repositories_controller.rb +++ b/app/controllers/platforms/repositories_controller.rb @@ -141,7 +141,12 @@ class Platforms::RepositoriesController < Platforms::BaseController end def regenerate_metadata - AbfWorker::BuildListsPublishTaskManager.repository_regenerate_metadata @repository.id + if Resque.redis.lrange(AbfWorker::BuildListsPublishTaskManager::REGENERATE_METADATA, 0, -1).include? @repository.id.to_s + flash[:error] = t('flash.repository.regenerate_already_in_queue') + else + AbfWorker::BuildListsPublishTaskManager.repository_regenerate_metadata @repository.id + flash[:notice] = t('flash.repository.regenerate_in_queue') + end redirect_to platform_repository_path(@platform, @repository) end diff --git a/config/locales/models/repository.en.yml b/config/locales/models/repository.en.yml index 3049627e2..11dcae4db 100644 --- a/config/locales/models/repository.en.yml +++ b/config/locales/models/repository.en.yml @@ -43,6 +43,8 @@ en: members: successfully_added: "%{name} successfully added to the repository" error_in_adding: "Unable to add %{name} as member" + regenerate_in_queue: Repository is queued for regenerate metadata + regenerate_already_in_queue: Repository is already queued for regenerate metadata activerecord: models: diff --git a/config/locales/models/repository.ru.yml b/config/locales/models/repository.ru.yml index db0ade89e..f5e5a58fa 100644 --- a/config/locales/models/repository.ru.yml +++ b/config/locales/models/repository.ru.yml @@ -43,6 +43,8 @@ ru: members: successfully_added: "Участник %{name} успешно добавлен к репозиторию" error_in_adding: "Не удалось добавить участника %{name}" + regenerate_in_queue: Репозиторий поставлен в очередь на регенерацию метаданных + regenerate_already_in_queue: Репозиторий уже в очереди на регенерацию метаданных activerecord: models: From 1a3db0481703e64676c0a91b4016da8c49366f29 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 13 Feb 2013 15:32:28 +0600 Subject: [PATCH 10/10] [refs #893] small refactoring --- app/controllers/platforms/repositories_controller.rb | 7 +++---- lib/abf_worker/build_lists_publish_task_manager.rb | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/platforms/repositories_controller.rb b/app/controllers/platforms/repositories_controller.rb index ea6c7293b..9b92e1360 100644 --- a/app/controllers/platforms/repositories_controller.rb +++ b/app/controllers/platforms/repositories_controller.rb @@ -141,11 +141,10 @@ class Platforms::RepositoriesController < Platforms::BaseController end def regenerate_metadata - if Resque.redis.lrange(AbfWorker::BuildListsPublishTaskManager::REGENERATE_METADATA, 0, -1).include? @repository.id.to_s - flash[:error] = t('flash.repository.regenerate_already_in_queue') - else - AbfWorker::BuildListsPublishTaskManager.repository_regenerate_metadata @repository.id + if AbfWorker::BuildListsPublishTaskManager.repository_regenerate_metadata @repository.id flash[:notice] = t('flash.repository.regenerate_in_queue') + else + flash[:error] = t('flash.repository.regenerate_already_in_queue') end redirect_to platform_repository_path(@platform, @repository) end diff --git a/lib/abf_worker/build_lists_publish_task_manager.rb b/lib/abf_worker/build_lists_publish_task_manager.rb index 99750f1ba..a49177389 100644 --- a/lib/abf_worker/build_lists_publish_task_manager.rb +++ b/lib/abf_worker/build_lists_publish_task_manager.rb @@ -53,6 +53,7 @@ module AbfWorker end def repository_regenerate_metadata(repository_id) + return false if Resque.redis.lrange(REGENERATE_METADATA, 0, -1).include? repository_id.to_s redis.lpush REGENERATE_METADATA, repository_id end