diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2013-08-12 17:28:31 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2013-08-12 17:28:31 -0700 |
commit | 7f01f7abee1ff8372cab1f34310ad16c1b40208f (patch) | |
tree | 3ca79ad88c957949278648eaf50507130793afb7 | |
parent | 62148fe95a1ce46f1de319b52dea8382c6e5d9e9 (diff) | |
download | chef-CHEF-4451.tar.gz |
CHEF-4451: automatic remote_file cache file genCHEF-4451
-rw-r--r-- | lib/chef/resource/remote_file.rb | 18 |
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 |