Method: FileCopy.sftp_mkdir_recursive

Defined in:
lib/file_copy/copy.rb

.sftp_mkdir_recursive(sftp, path) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/file_copy/copy.rb', line 49

def sftp_mkdir_recursive(sftp, path)
  dir_stat = nil
  begin
    Log.debug1("Stat remote dir: %s.", path)
    dir_stat = sftp.stat!(path).directory?
    Log.debug1("Stat result %s.", dir_stat)
  rescue Net::SFTP::StatusException
  end
  if !dir_stat
    Log.debug1("Directory does not exists: %s.", path)
    sftp_mkdir_recursive sftp, File.dirname(path)
    Log.debug1("Making dir %s.", path)
    response = sftp.mkdir!(path)
    Log.debug1("Making dir ok:%s.", response.ok?)
  end
end