lib/capistrano-extensions/deploy.rb in jtrupiano-capistrano-extensions-0.1.4 vs lib/capistrano-extensions/deploy.rb in jtrupiano-capistrano-extensions-0.1.6
- old
+ new
@@ -85,13 +85,13 @@
DESC
task :create_shared_file_column_dirs, :roles => :app, :except => { :no_release => true } do
mappings = content_directories.inject(shared_content) { |hsh, dir| hsh.merge({"content/#{dir}" => "public/#{dir}"}) }
mappings.each_pair do |remote, local|
run <<-CMD
+ umask 0022 &&
mkdir -p #{shared_path}/#{remote} &&
- ln -sf #{shared_path}/#{remote} #{latest_release}/#{local} &&
- chmod 755 -R #{shared_path}/#{remote}
+ ln -sf #{shared_path}/#{remote} #{latest_release}/#{local}
CMD
end
end
desc <<-DESC
@@ -259,25 +259,31 @@
folders = ["content"] + shared_content.keys
run "cd #{shared_path} && tar czf #{shared_path}/content_backup.tar.gz #{folders.join(' ')}"
#run "cd #{content_path} && tar czf #{shared_path}/content_backup.tar.gz *"
- get "#{shared_path}/content_backup.tar.gz", "#{application}-#{rails_env}-content_backup.tar.gz"
+ download("#{shared_path}/content_backup.tar.gz", "#{application}-#{rails_env}-content_backup.tar.gz")
run "rm -f #{shared_path}/content_backup.tar.gz"
end
desc <<-DESC
[capistrano-extensions]: Restores the backed up content (evn var FROM specifies which environment
was backed up, defaults to RAILS_ENV) to the local development environment app
DESC
task :restore_content do
from = ENV['FROM'] || rails_env
- system "tar xzf #{application}-#{from}-content_backup.tar.gz -C public/"
+ system "mkdir -p tmp/content-#{from}"
+ system "tar xzf #{application}-#{from}-content_backup.tar.gz -C tmp/content-#{from}"
system "rm -f #{application}-#{from}-content_backup.tar.gz"
shared_content.each_pair do |remote, local|
- system "rm -rf #{local} && mv public/#{remote} #{local}"
+ system "rm -rf #{local} && mv tmp/content-#{from}/#{remote} #{local}"
+ end
+
+ content_directories.each do |public_dir|
+ system "rm -rf public/#{public_dir}"
+ system "mv tmp/content-#{from}/content/#{public_dir} public/"
end
end
desc <<-DESC
\ No newline at end of file