Merge pull request #459 from warpc/438-remove_rsync_mount_from_app
[refs #438] Remove rsync mount and umount from platforms
This commit is contained in:
commit
1550d7a59e
|
@ -25,11 +25,12 @@ class Platform < ActiveRecord::Base
|
|||
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
|
||||
|
||||
|
||||
after_update :freeze_platform
|
||||
|
||||
after_create lambda { mount_directory_for_rsync unless hidden? }
|
||||
after_destroy lambda { umount_directory_for_rsync unless hidden? }
|
||||
|
||||
after_create lambda { symlink_directory unless hidden? }
|
||||
after_destroy lambda { remove_symlink_directory unless hidden? }
|
||||
|
||||
after_update :update_owner_relation
|
||||
|
||||
scope :search_order, order("CHAR_LENGTH(name) ASC")
|
||||
|
@ -46,7 +47,7 @@ class Platform < ActiveRecord::Base
|
|||
include Modules::Models::Owner
|
||||
|
||||
def urpmi_list(host, pair = nil)
|
||||
blank_pair = {:login => 'login', :pass => 'password'}
|
||||
blank_pair = {:login => 'login', :pass => 'password'}
|
||||
pair = blank_pair if pair.blank?
|
||||
urpmi_commands = ActiveSupport::OrderedHash.new
|
||||
|
||||
|
@ -67,7 +68,7 @@ class Platform < ActiveRecord::Base
|
|||
build_path(name)
|
||||
end
|
||||
|
||||
def mount_path
|
||||
def symlink_path
|
||||
Rails.root.join("public", "downloads", name)
|
||||
end
|
||||
|
||||
|
@ -119,14 +120,14 @@ class Platform < ActiveRecord::Base
|
|||
with_skip {c.save} and c.clone_relations(self) and c.delay.xml_rpc_clone
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def change_visibility
|
||||
if !self.hidden?
|
||||
self.update_attribute(:visibility, 'hidden')
|
||||
umount_directory_for_rsync
|
||||
remove_symlink_directory
|
||||
else
|
||||
self.update_attribute(:visibility, 'open')
|
||||
mount_directory_for_rsync
|
||||
symlink_directory
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -134,19 +135,18 @@ class Platform < ActiveRecord::Base
|
|||
system("sudo mkdir -p -m 0777 #{path}")
|
||||
end
|
||||
|
||||
def mount_directory_for_rsync
|
||||
def symlink_directory
|
||||
# umount_directory_for_rsync # TODO ignore errors
|
||||
system("sudo mkdir -p -m 0777 #{mount_path}")
|
||||
system("sudo mount --bind #{path} #{mount_path}")
|
||||
system("mkdir -p -m 0777 #{symlink_path}")
|
||||
system("ln -s #{path} #{symlink_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"
|
||||
File.open(File.join(mount_path, "#{name}.#{arch.name}.list"), 'w') {|f| f.write(str) }
|
||||
File.open(File.join(symlink_path, "#{name}.#{arch.name}.list"), 'w') {|f| f.write(str) }
|
||||
end
|
||||
end
|
||||
|
||||
def umount_directory_for_rsync
|
||||
system("sudo umount #{mount_path}")
|
||||
system("sudo rm -Rf #{mount_path}")
|
||||
def remove_symlink_directory
|
||||
system("rm -Rf #{symlink_path}")
|
||||
end
|
||||
|
||||
def update_owner_relation
|
||||
|
@ -214,6 +214,6 @@ class Platform < ActiveRecord::Base
|
|||
if released_changed? && released == true
|
||||
result = BuildServer.freeze(name)
|
||||
raise "Failed freeze platform #{name} with code #{result}" if result != BuildServer::SUCCESS
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -304,7 +304,7 @@ ActiveRecord::Schema.define(:version => 20120512102707) do
|
|||
t.integer "build_count", :default => 0, :null => false
|
||||
end
|
||||
|
||||
add_index "projects", ["owner_id"], :name => "index_projects_on_name_and_owner_id_and_owner_type", :unique => true, :case_sensitive => false
|
||||
add_index "projects", ["owner_id"], :name => "index_projects_on_name_and_owner_id_and_owner_type", :unique => true
|
||||
|
||||
create_table "register_requests", :force => true do |t|
|
||||
t.string "name"
|
||||
|
@ -312,8 +312,8 @@ ActiveRecord::Schema.define(:version => 20120512102707) do
|
|||
t.string "token"
|
||||
t.boolean "approved", :default => false
|
||||
t.boolean "rejected", :default => false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "interest"
|
||||
t.text "more"
|
||||
end
|
||||
|
@ -368,13 +368,14 @@ ActiveRecord::Schema.define(:version => 20120512102707) do
|
|||
t.string "email", :default => "", :null => false
|
||||
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
||||
t.string "reset_password_token"
|
||||
t.datetime "reset_password_sent_at"
|
||||
t.datetime "remember_created_at"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.text "ssh_key"
|
||||
t.string "uname"
|
||||
t.string "role"
|
||||
t.string "language", :default => "en"
|
||||
t.datetime "reset_password_sent_at"
|
||||
t.integer "own_projects_count", :default => 0, :null => false
|
||||
t.text "professional_experience"
|
||||
t.string "site"
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
namespace :downloads do
|
||||
|
||||
desc "Migrate from mount to symlinks"
|
||||
task :migrate => :environment do
|
||||
Platform.opened.each do |pl|
|
||||
system("sudo umount #{pl.symlink_path}")
|
||||
system("sudo rm -Rf #{pl.symlink_path}")
|
||||
|
||||
pl.symlink_directory
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -34,8 +34,8 @@ def set_session_for(user=nil)
|
|||
end
|
||||
|
||||
def stub_rsync_methods
|
||||
any_instance_of(Platform, :mount_directory_for_rsync => true)
|
||||
any_instance_of(Platform, :umount_directory_for_rsync => true)
|
||||
any_instance_of(Platform, :symlink_directory => true)
|
||||
any_instance_of(Platform, :remove_symlink_directory => true)
|
||||
end
|
||||
|
||||
def test_git_commit(project)
|
||||
|
|
Loading…
Reference in New Issue