Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6009

Show
Ignore:
Timestamp:
01/22/07 15:37:35 (2 years ago)
Author:
minam
Message:

Add a "get" helper, to pull a file from a remote server to the localhost (closes #6978). Also, fix a typo in standard.rb that caused a syntax error.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/capistrano/CHANGELOG

    r6008 r6009  
    11*SVN* 
     2 
     3* Add a "get" helper, to pull a file from a remote server to the localhost [bmihelac] 
    24 
    35* Fix gateway to actually increment local_port if a port is in use, so that multiple capistrano instances can run at the same time [Mark Imbriaco] 
  • tools/capistrano/lib/capistrano/actor.rb

    r5341 r6009  
    259259        run(cmd, options.merge(:data => data + "\n\4")) do |ch, stream, out| 
    260260          logger.important out, "#{stream} :: #{ch[:host]}" if stream == :err 
     261        end 
     262      end 
     263    end 
     264     
     265    # Get file remote_path from FIRST server targetted by 
     266    # the current task and transfer it to local machine as path. It will use 
     267    # SFTP if Net::SFTP is installed; otherwise it will fall back to using 
     268    # 'cat', which may cause corruption in binary files. 
     269    # 
     270    # get "#{deploy_to}/current/log/production.log", "log/production.log.web" 
     271    def get(remote_path, path, options = {}) 
     272      if Capistrano::SFTP && options.fetch(:sftp, true) 
     273        execute_on_servers(options.merge(:once => true)) do |servers| 
     274          logger.debug "downloading #{servers.first}:#{remote_path} to #{path}"  
     275          sessions[servers.first].sftp.connect do |tsftp| 
     276            tsftp.get_file remote_path, path 
     277          end 
     278          logger.trace "download finished"  
     279        end 
     280      else 
     281        logger.important "Net::SFTP is not available; using remote 'cat' to get file, which may cause file corruption" 
     282        File.open(path, "w") do |destination| 
     283          run "cat #{remote_path}", :once => true do |ch, stream, data| 
     284            case stream 
     285            when :out then destination << data 
     286            when :err then raise "error while downloading #{remote_path}: #{data.inspect}" 
     287            end 
     288          end 
    261289        end 
    262290      end 
  • tools/capistrano/lib/capistrano/recipes/standard.rb

    r5999 r6009  
    6767shared hosts. Override this task if you're on a shared host. 
    6868DESC 
    69 task :set_permissions 
     69task :set_permissions do 
    7070  run "chmod -R g+w #{release_path}" 
    7171end