Class: Wordmove::Actions::Ftp::PutAndImportDumpRemotely
- Inherits:
-
Object
- Object
- Wordmove::Actions::Ftp::PutAndImportDumpRemotely
- Extended by:
- LightService::Action
- Includes:
- Helpers, Helpers, WordpressDirectory::LocalHelperMethods, WordpressDirectory::RemoteHelperMethods
- Defined in:
- lib/wordmove/actions/ftp/put_and_import_dump_remotely.rb
Overview
Uploads a DB dump to remote host and import it in the remote database 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 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/wordmove/actions/ftp/put_and_import_dump_remotely.rb', line 27 executed do |context| # rubocop:disable Metrics/BlockLength context.logger.task 'Upload and import adapted DB' result = Wordmove::Actions::PutFile.execute( logger: context.logger, photocopier: context.photocopier, cli_options: context., command_args: [ context.db_paths.local.adapted_path, context.db_paths.remote.path ] ) context.fail_and_return!(result.) if result.failure? result = Wordmove::Actions::PutFile.execute( logger: context.logger, photocopier: context.photocopier, cli_options: context., command_args: [ context.db_paths.ftp.local.generated_import_script_path, context.db_paths.ftp.remote.import_script_path ] ) context.fail_and_return!(result.) if result.failure? import_url = [ context.db_paths.ftp.remote.import_script_url, '?shared_key=', context.db_paths.ftp.token, '&start=1&foffset=0&totalqueries=0&fn=dump.sql' ].join download(url: import_url, local_path: context.db_paths.ftp.local.temp_path) if context.[:debug] context.logger.debug "Operation log located at: #{context.db_paths.ftp.local.temp_path}" else result = Wordmove::Actions::DeleteLocalFile.execute( cli_options: context., logger: context.logger, file_path: context.db_paths.ftp.local.temp_path ) if result.failure? context.logger.warning 'Failed to delete local file ' \ "#{context.db_paths.ftp.local.temp_path} because: " \ "#{result.}" \ '. Manual intervention required' end end end |