Sha256: d4649ee443a0d270424e1720b7cc70b9907fee2d1f27a81b7d1fd6da8ea57d03

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require 'log4r'
require 'vagrant/util/subprocess'
require 'vagrant/util/which'

require_relative 'action/scp_sync'

module VagrantPlugins
  module ScpSync
    # This Class prepares the environment for SCP Sync
    class SyncedFolder < Vagrant.plugin('2', :synced_folder)
      include Vagrant::Util

      def initialize(*args)
        super

        @logger = Log4r::Logger.new('vagrant_scp_sync')
      end

      def usable?(_machine, *args)
        scp_path = Which.which('scp')
        return true if scp_path

        return false unless args.include?(:raise_error) && args[:raise_error]

        raise Vagrant::Errors::SCPNotFound
      end

      def prepare(machine, folders, opts); end

      def enable(machine, folders, _opts)
        ssh_info = machine.ssh_info
        # Still check if scp exists, but don't pass the path
        return false unless Which.which('scp')

        machine.ui.warn(I18n.t('vagrant.scp_ssh_password')) if ssh_info[:private_key_path].empty? && ssh_info[:password]

        folders.each_value do |folder_opts|
          ScpSyncHelper.scp_single(machine, folder_opts)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-scp-sync-0.5.26 lib/vagrant-scp-sync/synced_folder.rb