diff options
author | Jesse Campbell <hikeit@gmail.com> | 2013-03-01 11:11:05 -0500 |
---|---|---|
committer | Jesse Campbell <hikeit@gmail.com> | 2013-03-01 11:11:05 -0500 |
commit | 2139a6888756fdcedce559c9e38a8ea76a5f7b54 (patch) | |
tree | 480cebfe3c81d4b231800f869014afd99ae58f47 /lib/chef/provider/remote_file/local_file.rb | |
parent | 574d77db45f170e4c8297bfda2609a7eb7bed42b (diff) | |
download | chef-2139a6888756fdcedce559c9e38a8ea76a5f7b54.tar.gz |
strip target_matched, use tempfile=nil instead
Diffstat (limited to 'lib/chef/provider/remote_file/local_file.rb')
-rw-r--r-- | lib/chef/provider/remote_file/local_file.rb | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/lib/chef/provider/remote_file/local_file.rb b/lib/chef/provider/remote_file/local_file.rb index e9df6aa216..346867348d 100644 --- a/lib/chef/provider/remote_file/local_file.rb +++ b/lib/chef/provider/remote_file/local_file.rb @@ -23,22 +23,20 @@ require 'chef/provider/remote_file' class Chef class Provider class RemoteFile - class LocalFile < ::File + class LocalFile # Fetches the file at uri, returning a Tempfile-like File handle def self.fetch(uri, if_modified_since) - raw_file = LocalFile.new(uri.path) - mtime = raw_file.mtime - target_matched = mtime && if_modified_since && mtime.to_i <= if_modified_since.to_i - if target_matched - raw_file.close - raw_file = nil - end - return raw_file, mtime, target_matched - end - - def close! - close + mtime = ::File.mtime(uri.path) + if mtime && if_modified_since && mtime.to_i <= if_modified_since.to_i + tempfile = nil + else + tempfile = Tempfile.new(File.basename(uri.path)) + Chef::Log.debug("#{@new_resource} staging #{uri.path} to #{tempfile.path}") + FileUtils.cp(uri.path, tempfile.path) + tempfile + end + return tempfile, mtime end end |