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
|
@ -28,8 +28,9 @@ class Platform < ActiveRecord::Base
|
||||||
|
|
||||||
after_update :freeze_platform
|
after_update :freeze_platform
|
||||||
|
|
||||||
after_create lambda { mount_directory_for_rsync unless hidden? }
|
after_create lambda { symlink_directory unless hidden? }
|
||||||
after_destroy lambda { umount_directory_for_rsync unless hidden? }
|
after_destroy lambda { remove_symlink_directory unless hidden? }
|
||||||
|
|
||||||
after_update :update_owner_relation
|
after_update :update_owner_relation
|
||||||
|
|
||||||
scope :search_order, order("CHAR_LENGTH(name) ASC")
|
scope :search_order, order("CHAR_LENGTH(name) ASC")
|
||||||
|
@ -67,7 +68,7 @@ class Platform < ActiveRecord::Base
|
||||||
build_path(name)
|
build_path(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def mount_path
|
def symlink_path
|
||||||
Rails.root.join("public", "downloads", name)
|
Rails.root.join("public", "downloads", name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -123,10 +124,10 @@ class Platform < ActiveRecord::Base
|
||||||
def change_visibility
|
def change_visibility
|
||||||
if !self.hidden?
|
if !self.hidden?
|
||||||
self.update_attribute(:visibility, 'hidden')
|
self.update_attribute(:visibility, 'hidden')
|
||||||
umount_directory_for_rsync
|
remove_symlink_directory
|
||||||
else
|
else
|
||||||
self.update_attribute(:visibility, 'open')
|
self.update_attribute(:visibility, 'open')
|
||||||
mount_directory_for_rsync
|
symlink_directory
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -134,19 +135,18 @@ class Platform < ActiveRecord::Base
|
||||||
system("sudo mkdir -p -m 0777 #{path}")
|
system("sudo mkdir -p -m 0777 #{path}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def mount_directory_for_rsync
|
def symlink_directory
|
||||||
# umount_directory_for_rsync # TODO ignore errors
|
# umount_directory_for_rsync # TODO ignore errors
|
||||||
system("sudo mkdir -p -m 0777 #{mount_path}")
|
system("mkdir -p -m 0777 #{symlink_path}")
|
||||||
system("sudo mount --bind #{path} #{mount_path}")
|
system("ln -s #{path} #{symlink_path}")
|
||||||
Arch.all.each do |arch|
|
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"
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
def umount_directory_for_rsync
|
def remove_symlink_directory
|
||||||
system("sudo umount #{mount_path}")
|
system("rm -Rf #{symlink_path}")
|
||||||
system("sudo rm -Rf #{mount_path}")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_owner_relation
|
def update_owner_relation
|
||||||
|
|
|
@ -304,7 +304,7 @@ ActiveRecord::Schema.define(:version => 20120512102707) do
|
||||||
t.integer "build_count", :default => 0, :null => false
|
t.integer "build_count", :default => 0, :null => false
|
||||||
end
|
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|
|
create_table "register_requests", :force => true do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
|
@ -312,8 +312,8 @@ ActiveRecord::Schema.define(:version => 20120512102707) do
|
||||||
t.string "token"
|
t.string "token"
|
||||||
t.boolean "approved", :default => false
|
t.boolean "approved", :default => false
|
||||||
t.boolean "rejected", :default => false
|
t.boolean "rejected", :default => false
|
||||||
t.datetime "created_at"
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at", :null => false
|
||||||
t.string "interest"
|
t.string "interest"
|
||||||
t.text "more"
|
t.text "more"
|
||||||
end
|
end
|
||||||
|
@ -368,13 +368,14 @@ ActiveRecord::Schema.define(:version => 20120512102707) do
|
||||||
t.string "email", :default => "", :null => false
|
t.string "email", :default => "", :null => false
|
||||||
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
||||||
t.string "reset_password_token"
|
t.string "reset_password_token"
|
||||||
|
t.datetime "reset_password_sent_at"
|
||||||
t.datetime "remember_created_at"
|
t.datetime "remember_created_at"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
|
t.text "ssh_key"
|
||||||
t.string "uname"
|
t.string "uname"
|
||||||
t.string "role"
|
t.string "role"
|
||||||
t.string "language", :default => "en"
|
t.string "language", :default => "en"
|
||||||
t.datetime "reset_password_sent_at"
|
|
||||||
t.integer "own_projects_count", :default => 0, :null => false
|
t.integer "own_projects_count", :default => 0, :null => false
|
||||||
t.text "professional_experience"
|
t.text "professional_experience"
|
||||||
t.string "site"
|
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
|
end
|
||||||
|
|
||||||
def stub_rsync_methods
|
def stub_rsync_methods
|
||||||
any_instance_of(Platform, :mount_directory_for_rsync => true)
|
any_instance_of(Platform, :symlink_directory => true)
|
||||||
any_instance_of(Platform, :umount_directory_for_rsync => true)
|
any_instance_of(Platform, :remove_symlink_directory => true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_git_commit(project)
|
def test_git_commit(project)
|
||||||
|
|
Loading…
Reference in New Issue