summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/resource/remote_file.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb
index 24d2562a9b..a5fd238463 100644
--- a/lib/chef/resource/remote_file.rb
+++ b/lib/chef/resource/remote_file.rb
@@ -100,8 +100,18 @@ class Chef
)
end
+ # override superclass to add symbol for :path argument
+ def path(arg=nil)
+ set_or_return(
+ :path,
+ arg,
+ :kind_of => [ String, Symbol ]
+ )
+ end
+
def after_created
validate_source(@source)
+ handle_caching()
end
private
@@ -122,6 +132,14 @@ class Chef
false
end
+ def handle_caching
+ if path == :cache
+ uri = ::URI.parse(::URI.unescape(source[0]))
+ cache_file_path = ::File.join(Chef::Config[:file_cache_path], ::File.basename(uri.path))
+ cache_file_path.gsub!(::File::SEPARATOR, ::File::ALT_SEPARATOR) if Chef::Platform.windows?
+ path(cache_file_path)
+ end
+ end
end
end
end