Skip to content

Commit 158c286

Browse files
authored
Merge pull request #411 from Fjan/restore-userdir-relative-path
Restore ability to work with a relative path outside a `within` block
2 parents 05a4322 + abfb3d6 commit 158c286

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ appear at the top.
77

88
* Your contribution here!
99
* [#410](https://github.com/capistrano/sshkit/pull/410): call #to_s on remote so Pathnames don't go :boom: - [@UnderpantsGnome](https://github.com/UnderpantsGnome)
10+
* [#411](https://github.com/capistrano/sshkit/pull/410): fix upload!/download! relative to user dir that broke in #408 - [@Fjan](https://github.com/Fjan)
1011

1112
## [1.15.0][] (2017-11-03)
1213

lib/sshkit/backends/local.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def initialize(_ = nil, &block)
1111
end
1212

1313
def upload!(local, remote, options = {})
14-
remote = File.join(pwd_path, remote) unless remote.to_s.start_with?("/")
14+
remote = File.join(pwd_path, remote) unless remote.to_s.start_with?("/") || pwd_path.nil?
1515
if local.is_a?(String)
1616
if options[:recursive]
1717
FileUtils.cp_r(local, remote)
@@ -26,7 +26,7 @@ def upload!(local, remote, options = {})
2626
end
2727

2828
def download!(remote, local=nil, _options = {})
29-
remote = File.join(pwd_path, remote) unless remote.to_s.start_with?("/")
29+
remote = File.join(pwd_path, remote) unless remote.to_s.start_with?("/") || pwd_path.nil?
3030
if local.nil?
3131
FileUtils.cp(remote, File.basename(remote))
3232
else

lib/sshkit/backends/netssh.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ def assign_defaults
6363

6464
def upload!(local, remote, options = {})
6565
summarizer = transfer_summarizer('Uploading', options)
66-
remote = File.join(pwd_path, remote) unless remote.to_s.start_with?("/")
66+
remote = File.join(pwd_path, remote) unless remote.to_s.start_with?("/") || pwd_path.nil?
6767
with_ssh do |ssh|
6868
ssh.scp.upload!(local, remote, options, &summarizer)
6969
end
7070
end
7171

7272
def download!(remote, local=nil, options = {})
7373
summarizer = transfer_summarizer('Downloading', options)
74-
remote = File.join(pwd_path, remote) unless remote.to_s.start_with?("/")
74+
remote = File.join(pwd_path, remote) unless remote.to_s.start_with?("/") || pwd_path.nil?
7575
with_ssh do |ssh|
7676
ssh.scp.download!(remote, local, options, &summarizer)
7777
end

0 commit comments

Comments
 (0)