From 7f01f7abee1ff8372cab1f34310ad16c1b40208f Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Mon, 12 Aug 2013 17:28:31 -0700 Subject: CHEF-4451: automatic remote_file cache file gen --- lib/chef/resource/remote_file.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 -- cgit v1.2.1