Repository create/delete RPC calls

This commit is contained in:
Alexey Nayden 2011-04-07 13:27:50 +04:00
parent f27f5558e9
commit 5ca703b96b
1 changed files with 21 additions and 2 deletions

View File

@ -7,7 +7,8 @@ class Repository < ActiveRecord::Base
scope :recent, order("name ASC") scope :recent, order("name ASC")
before_create :create_directory before_create :xml_rpc_create
before_destroy :xml_rpc_destroy
def path def path
build_path(unixname) build_path(unixname)
@ -27,7 +28,6 @@ class Repository < ActiveRecord::Base
File.join(platform.path, dir) File.join(platform.path, dir)
end end
#TODO: Spec me
def create_directory def create_directory
exists = File.exists?(path) && File.directory?(path) exists = File.exists?(path) && File.directory?(path)
raise "Directory #{path} already exists" if exists raise "Directory #{path} already exists" if exists
@ -38,5 +38,24 @@ class Repository < ActiveRecord::Base
FileUtils.mv(build_path(unixname_was), buildpath(unixname)) FileUtils.mv(build_path(unixname_was), buildpath(unixname))
end end
end end
def xml_rpc_create
result = BuildServer.create_repo name, platform.name
if result == BuildServer::SUCCESS
return true
else
raise "Failed to create repository #{name} inside platform #{platform.name}."
end
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}."
end
end
end end