Skip to content

Commit

Permalink
Fixed CHEF-3564 so that remote_directory
Browse files Browse the repository at this point in the history
is not longer updated_by_last_action on every run by only putting converge_by blocks in places where remote_dir would directly execute code.
  • Loading branch information
tylercloke committed Nov 6, 2012
1 parent 1fe6f9a commit 926726f
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions lib/chef/provider/remote_directory.rb
Expand Up @@ -39,22 +39,18 @@ def action_create
name !~ /(?:^|#{Regexp.escape(::File::SEPARATOR)})\.\.?$/
end)

converge_by("Create managed files in directory") do
files_to_transfer.each do |cookbook_file_relative_path|
create_cookbook_file(cookbook_file_relative_path)
# the file is removed from the purge list
files_to_purge.delete(::File.join(@new_resource.path, cookbook_file_relative_path))
# parent directories are also removed from the purge list
directories=::File.dirname(::File.join(@new_resource.path, cookbook_file_relative_path)).split(::File::SEPARATOR)
for i in 0..directories.length-1
files_to_purge.delete(::File.join(directories[0..i]))
end
end
end

converge_by("Purge unmanaged files from directory") do
purge_unmanaged_files(files_to_purge)
files_to_transfer.each do |cookbook_file_relative_path|
create_cookbook_file(cookbook_file_relative_path)
# the file is removed from the purge list
files_to_purge.delete(::File.join(@new_resource.path, cookbook_file_relative_path))
# parent directories are also removed from the purge list
directories=::File.dirname(::File.join(@new_resource.path, cookbook_file_relative_path)).split(::File::SEPARATOR)
for i in 0..directories.length-1
files_to_purge.delete(::File.join(directories[0..i]))
end
end
purge_unmanaged_files(files_to_purge)
end

def action_create_if_missing
Expand Down

0 comments on commit 926726f

Please sign in to comment.