Class: Wordmove::Actions::Ftp::DownloadRemoteDb
- Inherits:
-
Object
- Object
- Wordmove::Actions::Ftp::DownloadRemoteDb
- Extended by:
- LightService::Action
- Includes:
- Helpers, Helpers, WordpressDirectory::LocalHelperMethods, WordpressDirectory::RemoteHelperMethods
- Defined in:
- lib/wordmove/actions/ftp/download_remote_db.rb
Overview
Downloads the remote DB over FTP protocol
Class Method Summary collapse
-
.execute ⇒ LightService::Context
Action’s context.
Class Method Details
.execute ⇒ LightService::Context
Returns Action’s context.
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 |
# File 'lib/wordmove/actions/ftp/download_remote_db.rb', line 27 executed do |context| # rubocop:disable Metrics/BlockLength context.logger.task 'Download remote DB' if simulate?(cli_options: context.) context.logger.info 'A dump of the remote DB would have been saved into ' \ "#{context.db_paths.local.path}, " \ 'but you\'re simulating' next context end result = Wordmove::Actions::PutFile.execute( photocopier: context.photocopier, logger: context.logger, cli_options: context., command_args: [ context.db_paths.ftp.local.generated_dump_script_path, context.db_paths.ftp.remote.dump_script_path ] ) context.fail_and_return!(result.) if result.failure? dump_url = [ context.db_paths.ftp.remote.dump_script_url, '?shared_key=', context.db_paths.ftp.token ].join begin download(url: dump_url, local_path: context.db_paths.local.path) rescue => _e # rubocop:disable Style/RescueStandardError context.fail_and_return!(e.) end unless File.exist? context.db_paths.local.path context.fail_and_return!('Download of remote DB failed') end context.logger.success "Remote DB dump downloaded in #{context.db_paths.local.path}" end |