Class: Wordmove::Actions::Ssh::CleanupAfterAdapt

Inherits:
Object
  • Object
show all
Extended by:
LightService::Action
Includes:
Helpers
Defined in:
lib/wordmove/actions/ssh/cleanup_after_adapt.rb

Overview

Cleanup file created during DB push/pull operations

Class Method Summary collapse

Class Method Details

.executeLightService::Context

Returns Action’s context.

Parameters:

  • db_paths (BbPathsConfig)

    Configuration object for database

  • cli_options (Hash)

    Command line options (with symbolized keys)

  • logger (Wordmove::Logger)

Returns:

  • (LightService::Context)

    Action’s context



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/wordmove/actions/ssh/cleanup_after_adapt.rb', line 19

executed do |context| # rubocop:disable Metrics/BlockLength
  context.logger.task 'Cleanup'

  if simulate?(cli_options: context.cli_options)
    context.logger.info 'No cleanup during simulation'
    next context
  end

  result = Wordmove::Actions::DeleteLocalFile.execute(
    logger: context.logger,
    cli_options: context.cli_options,
    file_path: context.db_paths.local.path
  )
  if result.failure?
    context.logger.warning 'Failed to delete local file ' \
                           "#{context.db_paths.local.path} because: " \
                           "#{result.message}" \
                           '. Manual intervention required'
  end

  result = Wordmove::Actions::DeleteLocalFile.execute(
    cli_options: context.cli_options,
    logger: context.logger,
    file_path: context.db_paths.local.gzipped_adapted_path
  )
  if result.failure?
    context.logger.warning 'Failed to delete local file ' \
                           "#{context.db_paths.local.gzipped_adapted_path} because: " \
                           "#{result.message}" \
                           '. Manual intervention required'
  end
end