Skip to content

Instantly share code, notes, and snippets.

@adamhjk
Created November 9, 2010 22:15
Show Gist options
  • Save adamhjk/669933 to your computer and use it in GitHub Desktop.
Save adamhjk/669933 to your computer and use it in GitHub Desktop.
def action_create
if @current_resource.to != ::File.expand_path(@new_resource.to, @new_resource.target_file)
noop "Creating a #{@new_resource.link_type} link from #{@new_resource.to} -> #{@new_resource.target_file} for #{@new_resource}" do
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
end
if @new_resource.link_type == :symbolic
set_owner unless @new_resource.owner.nil?
set_group unless @new_resource.group.nil?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment