Class: Imap::Backup::Uploader

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(folder, serializer) ⇒ Uploader

Returns a new instance of Uploader.


6
7
8
9
# File 'lib/imap/backup/uploader.rb', line 6

def initialize(folder, serializer)
  @folder = folder
  @serializer = serializer
end

Instance Attribute Details

#folderObject (readonly)

Returns the value of attribute folder.


3
4
5
# File 'lib/imap/backup/uploader.rb', line 3

def folder
  @folder
end

#serializerObject (readonly)

Returns the value of attribute serializer.


4
5
6
# File 'lib/imap/backup/uploader.rb', line 4

def serializer
  @serializer
end

Instance Method Details

#runObject


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/imap/backup/uploader.rb', line 11

def run
  if folder.uids.any?
    rename_serialized_folder
  else
    folder.create
    serializer.force_uid_validity(folder.uid_validity)
  end

  return if count.zero?

  Logger.logger.debug "[#{folder.name}] #{count} to restore"
  serializer.each_message(missing_uids).with_index do |(uid, message), i|
    upload_message uid, message, i + 1
  end
end