class InstanceAgent::Plugins::CodeDeployPlugin::RemoveCommand

Public Class Methods

new(location) click to toggle source
# File lib/instance_agent/plugins/codedeploy/install_instruction.rb, line 202
def initialize(location)
  @file_path = location
end

Public Instance Methods

execute() click to toggle source
# File lib/instance_agent/plugins/codedeploy/install_instruction.rb, line 206
def execute
  #If the file doesn't exist the command is ignored
  if File.symlink?(@file_path)
    FileUtils.rm(@file_path)
  elsif File.exist?(@file_path)
    if File.directory?(@file_path)
      # TODO (AWSGLUE-713): handle the exception if the directory is non-empty;
      # this might mean the customer has put files in this directory and we should
      # probably ignore the error and move on
      FileUtils.rmdir(@file_path)
    else
      FileUtils.rm(@file_path)
    end
  end
end