Skip to content

Commit

Permalink
Merge pull request #28 from racker-bobg/master
Browse files Browse the repository at this point in the history
fixes cloud files object download on every chef-client run
  • Loading branch information
gondoi committed Feb 20, 2015
2 parents 2fff4f0 + 9a9b5ca commit 35a982b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
license "Apache 2.0"
description "Provides LWRP's for managing Rackspace Cloud resources."
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.1.1"
version "0.1.3"

depends "xml"
9 changes: 6 additions & 3 deletions providers/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def load_current_resource

if ::File.exists?(@current_resource.filename)
@current_resource.exists = true
@current_resource.checksum = Chef::Digester.checksum_for_file(@current_resource.filename)
@current_resource.checksum = Chef::Digester.generate_md5_checksum_for_file(@current_resource.filename)
else
@current_resource.exists = false
end
Expand All @@ -51,14 +51,17 @@ def load_current_resource
directory = get_directory(new_resource.directory)
remote_file = directory.files.get(::File.basename(new_resource.filename))

if !current_resource.exists || remote_file.etag != current_resource.checksum
if current_resource.exists && remote_file.etag != current_resource.checksum
directory.files.get(::File.basename(new_resource.filename)) do |data, remaining, content_length|
f.syswrite data
end

converge_by("Moving new file with checksum to #{new_resource.filename}") do
move_file(f.path, new_resource.filename)
end
elsif !current_resource.exists
directory.files.get(::File.basename(new_resource.filename)) do |data, remaining, content_length|
f.syswrite data
end
else
f.unlink
end
Expand Down

0 comments on commit 35a982b

Please sign in to comment.