Sha256: f6db23c11203fa9d6f69b6bc3f1899043f7be3f13d895dd50a5e36a37348baef

Contents?: true

Size: 1.97 KB

Versions: 1

Compression:

Stored size: 1.97 KB

Contents

module Wordmove
  module Actions
    module Ssh
      # Cleanup file created during DB push/pull operations
      class CleanupAfterAdapt
        extend ::LightService::Action
        include Wordmove::Actions::Helpers

        expects :db_paths,
                :cli_options,
                :logger

        # @!method execute
        # @param db_paths [BbPathsConfig] Configuration object for database
        # @param cli_options [Hash] Command line options (with symbolized keys)
        # @param logger [Wordmove::Logger]
        # @!scope class
        # @return [LightService::Context] Action's context
        executed do |context|
          next context if context.database_task == false

          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
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wordmove-6.0.0.alpha.2 lib/wordmove/actions/ssh/cleanup_after_adapt.rb