Class: Imap::Backup::CLI::Transfer

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/imap/backup/cli/transfer.rb

Overview

Implements migration and mirroring

Constant Summary collapse

ACTIONS =

The possible values for the action parameter

i(copy migrate mirror).freeze

Constants included from Helpers

Helpers::NAMESPACE_CONFIGURATION_DESCRIPTION

Instance Method Summary collapse

Methods included from Helpers

#account, included, #load_config, #requested_accounts

Constructor Details

#initialize(action, source_email, destination_email, options) ⇒ Transfer

Returns a new instance of Transfer.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/imap/backup/cli/transfer.rb', line 19

def initialize(action, source_email, destination_email, options)
  @action = action
  @source_email = source_email
  @destination_email = destination_email
  @options = options
  @automatic_namespaces = nil
  @config_path = nil
  @destination_delimiter = nil
  @destination_locker = nil
  @destination_prefix = nil
  @reset = nil
  @source_delimiter = nil
  @source_locker = nil
  @source_prefix = nil
end

Instance Method Details

#runObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/imap/backup/cli/transfer.rb', line 42

def run
  raise "Unknown action '#{action}'" if !ACTIONS.include?(action)

  process_options!
   if action == :mirror

  run_backup if i(copy mirror).include?(action)

  source_locker.with_lock do
    destination_locker.with_lock do
      perform_action_on_folders
    end
  end
end