summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Kerry <jk185160@ncr.com>2016-04-05 14:33:41 -0400
committerJohn Kerry <jk185160@ncr.com>2016-04-05 14:33:41 -0400
commitda54509b1ec03be638e3e92faa17c00dfd3bb03c (patch)
tree18d7b01c43e92e774cef164cd40358b1d968c68b
parent2420f2ed69cd162893ee7430c2c01a03aa6107f0 (diff)
downloadchef-da54509b1ec03be638e3e92faa17c00dfd3bb03c.tar.gz
removing zombied references and migrating validation logic directly into the validate_path code.
-rw-r--r--lib/chef/provider/remote_file/sftp.rb36
1 files changed, 13 insertions, 23 deletions
diff --git a/lib/chef/provider/remote_file/sftp.rb b/lib/chef/provider/remote_file/sftp.rb
index 87aa8d0398..a53864de49 100644
--- a/lib/chef/provider/remote_file/sftp.rb
+++ b/lib/chef/provider/remote_file/sftp.rb
@@ -50,11 +50,6 @@ class Chef
URI.unescape(uri.user)
end
- def filename
- parse_path if @filename.nil?
- @filename
- end
-
def fetch
get
end
@@ -71,7 +66,19 @@ class Chef
end
def validate_path!
- parse_path
+ path = uri.path.sub(%r{\A/}, "%2F") # re-encode the beginning slash because uri library decodes it.
+ directories = path.split(%r{/}, -1)
+ directories.each {|d|
+ d.gsub!(/%([0-9A-Fa-f][0-9A-Fa-f])/) { [$1].pack("H2") }
+ }
+ unless filename = directories.pop
+ raise ArgumentError, "no filename: #{path.inspect}"
+ end
+ if filename.length == 0 || filename.end_with?( "/" )
+ raise ArgumentError, "no filename: #{path.inspect}"
+ end
+
+ @directories, @filename = directories, filename
end
def validate_userinfo!
@@ -95,23 +102,6 @@ class Chef
tempfile.close if tempfile
tempfile
end
-
- def parse_path
- path = uri.path.sub(%r{\A/}, "%2F") # re-encode the beginning slash because uri library decodes it.
- directories = path.split(%r{/}, -1)
- directories.each {|d|
- d.gsub!(/%([0-9A-Fa-f][0-9A-Fa-f])/) { [$1].pack("H2") }
- }
- unless filename = directories.pop
- raise ArgumentError, "no filename: #{path.inspect}"
- end
- if filename.length == 0 || filename.end_with?( "/" )
- raise ArgumentError, "no filename: #{path.inspect}"
- end
-
- @directories, @filename = directories, filename
- end
-
end
end
end