diff --git a/app/models/platform.rb b/app/models/platform.rb index db48d9179..9edefd617 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -197,21 +197,15 @@ class Platform < ActiveRecord::Base end def xml_rpc_create - result = BuildServer.add_platform name, APP_CONFIG['root_path'] + '/platforms' , distrib_type - if result == BuildServer::SUCCESS - return true - else - raise "Failed to create platform #{name} with code #{result}. Path: #{build_path(name)}" - end + Resque.enqueue(AbfWorker::FileSystemWorker, + {:id => id, :action => 'create', :type => 'platform'}) + return true end def xml_rpc_destroy - result = BuildServer.delete_platform name - if result == BuildServer::SUCCESS - return true - else - raise "Failed to delete platform #{name} with code #{result}." - end + Resque.enqueue(AbfWorker::FileSystemWorker, + {:id => id, :action => 'destroy', :type => 'platform'}) + return true end def xml_rpc_clone(old_name = parent.name, new_name = name) diff --git a/app/models/repository.rb b/app/models/repository.rb index 22afd8456..16409a900 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -61,6 +61,7 @@ class Repository < ActiveRecord::Base protected + # TODO: remove it, when will be used new_core only. def xml_rpc_create result = BuildServer.create_repo name, platform.name if result == BuildServer::SUCCESS @@ -71,11 +72,8 @@ class Repository < ActiveRecord::Base end def xml_rpc_destroy - result = BuildServer.delete_repo name, platform.name - if result == BuildServer::SUCCESS - return true - else - raise "Failed to delete repository #{name} inside platform #{platform.name} with code #{result}." - end + Resque.enqueue(AbfWorker::FileSystemWorker, + {:id => id, :action => 'destroy', :type => 'repository'}) + return true end end diff --git a/lib/abf_worker/file_system_worker.rb b/lib/abf_worker/file_system_worker.rb index 580602043..6ef075470 100644 --- a/lib/abf_worker/file_system_worker.rb +++ b/lib/abf_worker/file_system_worker.rb @@ -9,8 +9,6 @@ module AbfWorker @runner = AbfWorker::Runners::Platform.new id, action when 'repository' @runner = AbfWorker::Runners::Repository.new id, action - when 'project' - @runner = AbfWorker::Runners::Project.new id, action end @runner.run end diff --git a/lib/abf_worker/runners/repository.rb b/lib/abf_worker/runners/repository.rb index 4aa018ec0..b3a45094c 100644 --- a/lib/abf_worker/runners/repository.rb +++ b/lib/abf_worker/runners/repository.rb @@ -10,19 +10,6 @@ module AbfWorker protected - def create - platform = @repository.platform - repository_path = platform.path - repository_path << '/repository' - if platform.personal? - Platform.main.pluck(:name).each do |main_platform_name| - create_file_tree "#{repository_path}/#{main_platform_name}", true - end - else - create_file_tree repository_path - end - end - def destroy platform = @repository.platform repository_path = platform.path @@ -43,40 +30,6 @@ module AbfWorker system("rm -rf #{repository_path}/SRPMS/#{@repository.name}") end - def create_file_tree(repository_path, personal = false) - # platforms/rosa2012.1/repository - # platforms/test_personal/repository/rosa2012.1 - mk_dir repository_path - Arch.pluck(:name).each do |arch| - path = "#{repository_path}/#{arch}" - # platforms/rosa2012.1/repository/i586 - # platforms/test_personal/repository/rosa2012.1/i586 - mk_dir path - path << '/' << @repository.name - # platforms/rosa2012.1/repository/i586/main - # platforms/test_personal/repository/rosa2012.1/i586/main - mk_dir path - # platforms/rosa2012.1/repository/i586/main/release - # platforms/test_personal/repository/rosa2012.1/i586/main/release - mk_dir "#{path}/release" - # platforms/rosa2012.1/repository/i586/main/updates - mk_dir "#{path}/updates" unless personal - end - path = "#{repository_path}/SRPMS" - # platforms/rosa2012.1/repository/SRPMS - # platforms/test_personal/repository/rosa2012.1/SRPMS - mk_dir path - path << '/' << @repository.name - # platforms/rosa2012.1/repository/SRPMS/main - # platforms/test_personal/repository/rosa2012.1/SRPMS/main - mk_dir path - # platforms/rosa2012.1/repository/SRPMS/main/release - # platforms/test_personal/repository/rosa2012.1/SRPMS/main/release - mk_dir "#{path}/release" - # platforms/rosa2012.1/repository/SRPMS/main/updates - mk_dir "#{path}/updates" unless personal - end - end end end \ No newline at end of file diff --git a/lib/recipes/resque.rb b/lib/recipes/resque.rb index 19bb7d23a..be682f2e8 100644 --- a/lib/recipes/resque.rb +++ b/lib/recipes/resque.rb @@ -26,7 +26,16 @@ Capistrano::Configuration.instance(:must_exist).load do end def start_workers - run "cd #{fetch :current_path} && COUNT=#{workers_count} QUEUE=fork_import,hook,clone_build,notification,iso_worker_observer,rpm_worker_observer #{rails_env} BACKGROUND=yes bundle exec rake resque:workers" + queue = [ + :fork_import, + :hook, + :clone_build, + :notification, + :iso_worker_observer, + :rpm_worker_observer, + :file_system_worker + ].join(',') + run "cd #{fetch :current_path} && COUNT=#{workers_count} QUEUE=#{queue} #{rails_env} BACKGROUND=yes bundle exec rake resque:workers" end end end