[refs #438] Add rake task to symlink migrate. Change rsync stubs

This commit is contained in:
konstantin.grabar 2012-05-16 17:01:25 +04:00
parent 2c4169a3c7
commit 208310e83b
4 changed files with 23 additions and 9 deletions

View File

@ -135,8 +135,8 @@ class Platform < ActiveRecord::Base
def symlink_directory
# umount_directory_for_rsync # TODO ignore errors
system("sudo mkdir -p -m 0777 #{symlink_path}")
system("sudo ln -s #{path} #{symlink_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(symlink_path, "#{name}.#{arch.name}.list"), 'w') {|f| f.write(str) }
@ -144,7 +144,7 @@ class Platform < ActiveRecord::Base
end
def remove_symlink_directory
system("sudo rm -Rf #{symlink_path}")
system("rm -Rf #{symlink_path}")
end
def update_owner_relation

View File

@ -287,7 +287,7 @@ ActiveRecord::Schema.define(:version => 20120505101650) 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"
@ -295,8 +295,8 @@ ActiveRecord::Schema.define(:version => 20120505101650) 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
@ -351,13 +351,14 @@ ActiveRecord::Schema.define(:version => 20120505101650) 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"

View File

@ -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

View File

@ -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)