@@ -30,6 +30,9 @@ module Net; module SFTP; module Operations
30
30
# This will upload "/path/to/directory", it's contents, it's subdirectories,
31
31
# and their contents, recursively, to "/path/to/remote" on the remote server.
32
32
#
33
+ # For uploading a directory without creating it, do
34
+ # sftp.upload!("/path/to/directory", "/path/to/remote", :create_dir => false)
35
+ #
33
36
# If you want to send data to a file on the remote server, but the data is
34
37
# in memory, you can pass an IO object and upload it's contents:
35
38
#
@@ -157,12 +160,17 @@ def initialize(sftp, local, remote, options={}, &progress) #:nodoc:
157
160
@remote_cwd = remote
158
161
159
162
@active += 1
160
- sftp . mkdir ( remote ) do |response |
161
- @active -= 1
162
- raise StatusException . new ( response , "mkdir `#{ remote } '" ) unless response . ok?
163
- ( options [ :requests ] || RECURSIVE_READERS ) . to_i . times do
164
- break unless process_next_entry
163
+ if @options [ :create_dir ]
164
+ sftp . mkdir ( remote ) do |response |
165
+ @active -= 1
166
+ raise StatusException . new ( response , "mkdir `#{ remote } '" ) unless response . ok?
167
+ ( options [ :requests ] || RECURSIVE_READERS ) . to_i . times do
168
+ break unless process_next_entry
169
+ end
165
170
end
171
+ else
172
+ @active -= 1
173
+ process_next_entry
166
174
end
167
175
else
168
176
raise ArgumentError , "expected a file to upload" unless local . respond_to? ( :read ) || ::File . exists? ( local )
0 commit comments