diff --git a/app/models/platform.rb b/app/models/platform.rb index 3b7551703..713283b5c 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -18,6 +18,7 @@ class Platform < ActiveRecord::Base validates :name, :uniqueness => {:case_sensitive => false}, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-]+$/ } validates :distrib_type, :presence => true, :inclusion => {:in => APP_CONFIG['distr_types']} + before_create :create_directory, :if => lambda {Thread.current[:skip]} # TODO remove this when core will be ready before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]} before_destroy :xml_rpc_destroy # before_update :check_freezing @@ -131,9 +132,13 @@ class Platform < ActiveRecord::Base end end + def create_directory + system("sudo mkdir -p -m 0777 #{path}") + end + def mount_directory_for_rsync # umount_directory_for_rsync # TODO ignore errors - system("sudo mkdir -p #{mount_path}") + system("sudo mkdir -p -m 0777 #{mount_path}") system("sudo mount --bind #{path} #{mount_path}") Arch.all.each do |arch| str = "country=Russian Federation,city=Moscow,latitude=52.18,longitude=48.88,bw=1GB,version=2011,arch=#{arch.name},type=distrib,url=#{public_downloads_url}\n" @@ -153,6 +158,10 @@ class Platform < ActiveRecord::Base end end + def destroy + with_skip {super} # avoid cascade XML RPC requests + end + protected def build_path(dir) diff --git a/app/models/project_to_repository.rb b/app/models/project_to_repository.rb index 7bf5adba5..611bb0bbe 100644 --- a/app/models/project_to_repository.rb +++ b/app/models/project_to_repository.rb @@ -6,7 +6,7 @@ class ProjectToRepository < ActiveRecord::Base delegate :path, :to => :project after_create lambda { project.xml_rpc_create(repository) }, :unless => lambda {Thread.current[:skip]} - after_destroy lambda { project.xml_rpc_destroy(repository) } + after_destroy lambda { project.xml_rpc_destroy(repository) }, :unless => lambda {Thread.current[:skip]} # after_rollback lambda { project.xml_rpc_destroy(repository) rescue true if new_record? } validate :one_project_in_platform_repositories diff --git a/app/models/repository.rb b/app/models/repository.rb index 50b57cb4a..7684ee005 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -11,7 +11,7 @@ class Repository < ActiveRecord::Base scope :recent, order("name ASC") before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]} - before_destroy :xml_rpc_destroy + before_destroy :xml_rpc_destroy, :unless => lambda {Thread.current[:skip]} attr_accessible :description, :name diff --git a/lib/build_server.rb b/lib/build_server.rb index feb066b19..2bf6cfc9a 100644 --- a/lib/build_server.rb +++ b/lib/build_server.rb @@ -49,10 +49,12 @@ class BuildServer end def self.clone_repo new_name, old_name, new_platform_name + tmp = self.client.timeout # TODO remove this when core will be ready + self.client.timeout = 30.minutes self.client.call('clone_repo', new_name, old_name, new_platform_name) + self.client.timeout = tmp end - def self.publish_container container_id self.client.call('publish_container', container_id) end diff --git a/lib/modules/models/rsync_stub.rb b/lib/modules/models/rsync_stub.rb index bbf101d76..7865c232f 100644 --- a/lib/modules/models/rsync_stub.rb +++ b/lib/modules/models/rsync_stub.rb @@ -5,6 +5,10 @@ module Modules extend ActiveSupport::Concern included do + def create_directory + true + end + def mount_directory_for_rsync true end