Class: WinRM::FS::Core::UploadOrchestrator

Inherits:
Object
  • Object
show all
Defined in:
lib/winrm-fs/core/upload_orchestrator.rb

Overview

Orchestrates the upload of a file or directory

Instance Method Summary collapse

Constructor Details

#initialize(service) ⇒ UploadOrchestrator

Returns a new instance of UploadOrchestrator.



27
28
29
30
# File 'lib/winrm-fs/core/upload_orchestrator.rb', line 27

def initialize(service)
  @service = service
  @logger = Logging.logger[self]
end

Instance Method Details

#upload_directory(local_path, remote_path) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/winrm-fs/core/upload_orchestrator.rb', line 45

def upload_directory(local_path, remote_path)
  with_local_zip(local_path) do |local_zip|
    temp_path = temp_file_path(local_zip.path)
    with_command_executor do |cmd_executor|
      return 0 unless out_of_date?(cmd_executor, local_zip.path, temp_path)
      do_file_upload(cmd_executor, local_zip.path, temp_path, remote_path)
    end
  end
end

#upload_file(local_path, remote_path) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/winrm-fs/core/upload_orchestrator.rb', line 32

def upload_file(local_path, remote_path)
  # If the src has a file extension and the destination does not
  # we can assume the caller specified the dest as a directory
  if File.extname(local_path) != '' && File.extname(remote_path) == ''
    remote_path = File.join(remote_path, File.basename(local_path))
  end
  temp_path = temp_file_path(local_path)
  with_command_executor do |cmd_executor|
    return 0 unless out_of_date?(cmd_executor, local_path, remote_path)
    do_file_upload(cmd_executor, local_path, temp_path, remote_path)
  end
end