lib/fulmar/infrastructure/service/transfer/rsync.rb in fulmar-1.8.1 vs lib/fulmar/infrastructure/service/transfer/rsync.rb in fulmar-1.8.2

- old
+ new

@@ -1,6 +1,6 @@ - +require 'pathname' require 'fulmar/infrastructure/service/transfer/base' module Fulmar module Infrastructure module Service @@ -36,26 +36,34 @@ end # Build the rsync command from the given options def rsync_command if @config[:rsync][:direction] == 'up' - from = @config[:local_path] + from = absolute_path(@config[:local_path]) to = @config.ssh_user_and_host + ':' + @config[:remote_path] else from = @config.ssh_user_and_host + ':' + @config[:remote_path] - to = @config[:local_path] + to = absolute_path(@config[:local_path]) end - "rsync #{rsync_command_options.join(' ')} '#{from}/' '#{to}'" end # Gets the absolute release path # @return [String] the release directory def release_path @config[:remote_path] end protected + + # Get the absolute path of the given path + # @param [String] path + # @return [String] absolute path + def absolute_path(path) + path = Pathname.new(path) + return Pathname.new(@config.base_path) + path unless path.absolute? + path + end # Assembles all rsync command line parameters from the configuration options def rsync_command_options options = ['-rl'] options << "--exclude='#{@config[:rsync][:exclude]}'" if @config[:rsync][:exclude]