def action_create
if @current_resource.to != ::File.expand_path(@new_resource.to, @new_resource.target_file)
Chef::Log.info("Creating a #{@new_resource.link_type} link from #{@new_resource.to} -> #{@new_resource.target_file} for #{@new_resource}")
if @new_resource.link_type == :symbolic
unless (::File.symlink?(@new_resource.target_file) && ::File.readlink(@new_resource.target_file) == @new_resource.to)
if ::File.symlink?(@new_resource.target_file) || ::File.exist?(@new_resource.target_file)
::File.unlink(@new_resource.target_file)
end
::File.symlink(@new_resource.to,@new_resource.target_file)
end
elsif @new_resource.link_type == :hard
::File.link(@new_resource.to, @new_resource.target_file)
end
@new_resource.updated_by_last_action(true)
end
if @new_resource.link_type == :symbolic
set_owner unless @new_resource.owner.nil?
set_group unless @new_resource.group.nil?
end
end