How can I create a directory on Ruby via SFTP only when the directory doesn't exist?
I have the following code right now:
Net::SFTP.start( ip, id, :password => pass, :port=> port ) do |sftp|
sftp.mkdir! remotePath
sftp.upload!(localPath + localfile, remotePath + remotefile)
end
I have no problem creating the directory the first time but it tries to recreate the same directory even if it already exists and it throws me an error.
Anyone who knows how to do this?
In using fileutils, there is this code like:
FileUtils.mkdir_p(remotePath) unless File.exists?(remotePath)
Is there any way I could do the same over SFTP?