Class: InstanceAgent::Plugins::CodeDeployPlugin::RemoveCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/instance_agent/plugins/codedeploy/install_instruction.rb

Instance Method Summary collapse

Constructor Details

#initialize(location) ⇒ RemoveCommand

Returns a new instance of RemoveCommand.



202
203
204
# File 'lib/instance_agent/plugins/codedeploy/install_instruction.rb', line 202

def initialize(location)
  @file_path = location
end

Instance Method Details

#executeObject



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# 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