Skip to content

Commit

Permalink
fix honour passive ftp option
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandro-fazzi committed Aug 3, 2018
1 parent b347451 commit 1f0a4f8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/photocopier/ftp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def lftp(local, remote, reverse, exclude, port = nil)
local = Shellwords.escape(local)
command = [
"set ftp:list-options -a",
"set ftp:passive-mode #{options[:passive] || 'false'}",
"set cmd:fail-exit true",
"open -p #{port || inferred_port} #{remote_ftp_url}",
"find -d 1 #{remote} || mkdir -p #{remote}",
Expand Down
4 changes: 2 additions & 2 deletions lib/photocopier/ftp/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def initialize(options)
options[:host],
username: options[:user],
password: options[:password],
port: options[:port] || 21
port: options[:port] || 21,
passive: options[:passive] || false
)
@session.passive = options[:passive] if options.key?(:passive)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/photocopier/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_litterla: true

module Photocopier
VERSION = "1.3.0".freeze
VERSION = "1.3.1".freeze
end
4 changes: 3 additions & 1 deletion spec/ftp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"host",
username: "user",
password: "password",
port: 2121
port: 2121,
passive: false
)
ftp.send(:session)
end
Expand Down Expand Up @@ -118,6 +119,7 @@
let(:lftp_commands) do
[
'set ftp:list-options -a',
'set ftp:passive-mode false',
'set cmd:fail-exit true',
"open -p #{ftp.inferred_port} #{options[:scheme] || 'ftp'}://user:pass%21%22%27%2C%3B%24u%26V%[email protected]",
'find -d 1 remote\\ dir || mkdir -p remote\\ dir',
Expand Down

0 comments on commit 1f0a4f8

Please sign in to comment.