Merge pull request #212 from warpc/207-platform_clone_bg
Create directory for platform before clone. Fix created directory permissions. Increase timeout during XML RPC clone. Switch off cascade XML RPC requests during platform destroy. Refs #207
This commit is contained in:
commit
e3c6a23eb6
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -5,6 +5,10 @@ module Modules
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
def create_directory
|
||||
true
|
||||
end
|
||||
|
||||
def mount_directory_for_rsync
|
||||
true
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue