Class: Wordmove::Actions::Ftp::CleanupAfterAdapt
- Inherits:
-
Object
- Object
- Wordmove::Actions::Ftp::CleanupAfterAdapt
- Extended by:
- LightService::Action
- Includes:
- Helpers
- Defined in:
- lib/wordmove/actions/ftp/cleanup_after_adapt.rb
Overview
Cleanup file created during DB push/pull operations
Class Method Summary collapse
-
.execute ⇒ LightService::Context
Action’s context.
Class Method Details
.execute ⇒ LightService::Context
Returns Action’s context.
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/wordmove/actions/ftp/cleanup_after_adapt.rb', line 21 executed do |context| # rubocop:disable Metrics/BlockLength context.logger.task 'Cleanup' if simulate?(cli_options: context.) context.logger.info 'No cleanup during simulation' next context end result = Wordmove::Actions::DeleteLocalFile.execute( logger: context.logger, cli_options: context., 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.}" \ '. Manual intervention required' end [ context.db_paths.ftp.remote.dump_script_path, context.db_paths.ftp.remote.import_script_path, context.db_paths.remote.path, context.db_paths.ftp.remote.dumped_path ].each do |file| begin result = Wordmove::Actions::DeleteRemoteFile.execute( photocopier: context.photocopier, logger: context.logger, cli_options: context., remote_file: file ) rescue Net::FTPPermError => _e context.logger.info "#{file} doesn't exist remotely. Nothing to cleanup" end if result.failure? # rubocop:disable Style/Next context.logger.warning 'Failed to delete remote file ' \ "#{file} because: " \ "#{result.}" \ '. Manual intervention required' end end end |