Disable XML callbacks during platform clone. Code cleanup. Refs #2162

This commit is contained in:
Pavel Chipiga 2011-11-03 22:41:06 +02:00
parent fb165483b8
commit a725a51bc3
3 changed files with 10 additions and 8 deletions

View File

@ -23,7 +23,7 @@ class Platform < ActiveRecord::Base
before_save :check_owner_rel before_save :check_owner_rel
# before_save :create_directory # before_save :create_directory
# after_destroy :remove_directory # after_destroy :remove_directory
before_create :xml_rpc_create before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]}
before_destroy :xml_rpc_destroy before_destroy :xml_rpc_destroy
# before_update :check_freezing # before_update :check_freezing
after_create lambda { add_downloads_symlink unless self.hidden? } after_create lambda { add_downloads_symlink unless self.hidden? }
@ -36,7 +36,6 @@ class Platform < ActiveRecord::Base
#attr_accessible :visibility #attr_accessible :visibility
def urpmi_list(host, pair = nil) def urpmi_list(host, pair = nil)
blank_pair = {:login => 'login', :pass => 'password'} blank_pair = {:login => 'login', :pass => 'password'}
pair = blank_pair if pair.blank? pair = blank_pair if pair.blank?
@ -83,7 +82,13 @@ class Platform < ActiveRecord::Base
# TODO * make it Delayed Job * # TODO * make it Delayed Job *
def make_clone(attrs) def make_clone(attrs)
p = full_clone(attrs) p = full_clone(attrs)
p.save and xml_rpc_clone(attrs[:unixname]) begin
Thread.current[:skip] = true
p.save and xml_rpc_clone(attrs[:unixname])
ensure
Thread.current[:skip] = false
end
# (Thread.current[:skip] = true) and p.save and (Thread.current[:skip] = false or true) and xml_rpc_clone(attrs[:unixname])
p p
end end
@ -157,7 +162,6 @@ class Platform < ActiveRecord::Base
end end
def xml_rpc_create def xml_rpc_create
# return true
result = BuildServer.add_platform unixname, APP_CONFIG['root_path'] + '/platforms' , distrib_type result = BuildServer.add_platform unixname, APP_CONFIG['root_path'] + '/platforms' , distrib_type
if result == BuildServer::SUCCESS if result == BuildServer::SUCCESS
return true return true
@ -167,7 +171,6 @@ class Platform < ActiveRecord::Base
end end
def xml_rpc_destroy def xml_rpc_destroy
# return true
result = BuildServer.delete_platform unixname result = BuildServer.delete_platform unixname
if result == BuildServer::SUCCESS if result == BuildServer::SUCCESS
return true return true
@ -177,7 +180,6 @@ class Platform < ActiveRecord::Base
end end
def xml_rpc_clone(new_unixname) def xml_rpc_clone(new_unixname)
# return true
result = BuildServer.clone_platform new_unixname, self.unixname, APP_CONFIG['root_path'] + '/platforms' result = BuildServer.clone_platform new_unixname, self.unixname, APP_CONFIG['root_path'] + '/platforms'
if result == BuildServer::SUCCESS if result == BuildServer::SUCCESS
return true return true

View File

@ -9,7 +9,7 @@ class ProjectToRepository < ActiveRecord::Base
#after_destroy :remove_link #after_destroy :remove_link
#after_destroy :remove_compability_link #after_destroy :remove_compability_link
after_create lambda { project.xml_rpc_create(repository) } 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) }
after_rollback lambda { project.xml_rpc_destroy(repository) rescue true if new_record? } after_rollback lambda { project.xml_rpc_destroy(repository) rescue true if new_record? }

View File

@ -23,7 +23,7 @@ class Repository < ActiveRecord::Base
#before_save :add_owner_rel #before_save :add_owner_rel
#after_destroy :remove_directory #after_destroy :remove_directory
before_create :xml_rpc_create before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]}
before_destroy :xml_rpc_destroy before_destroy :xml_rpc_destroy
attr_accessible :name, :unixname, :platform_id attr_accessible :name, :unixname, :platform_id