Class: Imap::Backup::Serializer::Version2Migrator

Inherits:
Object
  • Object
show all
Defined in:
lib/imap/backup/serializer/version2_migrator.rb

Instance Method Summary collapse

Constructor Details

#initialize(folder_path) ⇒ Version2Migrator

Returns a new instance of Version2Migrator.



9
10
11
# File 'lib/imap/backup/serializer/version2_migrator.rb', line 9

def initialize(folder_path)
  @folder_path = folder_path
end

Instance Method Details

#required?Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
22
# File 'lib/imap/backup/serializer/version2_migrator.rb', line 13

def required?
  return false if !mbox_exists?
  return false if !imap_exists?
  return false if !imap_data
  return false if imap_data[:version] != 2
  return false if !imap_data[:uid_validity]
  return false if !uids.is_a?(Array)

  true
end

#runObject



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/imap/backup/serializer/version2_migrator.rb', line 24

def run
  return false if !required?

  messages = message_uids_and_lengths

  return false if !messages

  imap.delete
  imap.uid_validity = imap_data[:uid_validity]
  messages.map { |m| imap.append(m[:uid], m[:length]) }

  true
end