lib/imap/backup/cli/transfer.rb in imap-backup-14.6.1 vs lib/imap/backup/cli/transfer.rb in imap-backup-15.0.0

- old
+ new

@@ -11,11 +11,11 @@ # Implements migration and mirroring class CLI::Transfer include CLI::Helpers # The possible values for the action parameter - ACTIONS = %i(migrate mirror).freeze + ACTIONS = %i(copy migrate mirror).freeze def initialize(action, source_email, destination_email, options) @action = action @source_email = source_email @destination_email = destination_email @@ -37,18 +37,21 @@ # @return [void] def run raise "Unknown action '#{action}'" if !ACTIONS.include?(action) process_options! - prepare_mirror if action == :mirror + warn_if_source_account_is_not_in_mirror_mode if action == :mirror + run_backup if %i(copy mirror).include?(action) folders.each do |serializer, folder| case action + when :copy + Mirror.new(serializer, folder, reset: false).run when :migrate Migrator.new(serializer, folder, reset: reset).run when :mirror - Mirror.new(serializer, folder).run + Mirror.new(serializer, folder, reset: true).run end end end private @@ -121,12 +124,10 @@ self.destination_prefix ||= "" self.source_delimiter ||= "/" self.source_prefix ||= "" end - def prepare_mirror - warn_if_source_account_is_not_in_mirror_mode - + def run_backup CLI::Backup.new(config: config_path, accounts: source_email).run end def warn_if_source_account_is_not_in_mirror_mode return if source_account.mirror_mode