Class: Imap::Backup::Uploader

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

Overview

Uploads a backed-up folder

Instance Method Summary collapse

Constructor Details

#initialize(folder, serializer) ⇒ Uploader

Returns a new instance of Uploader.

Parameters:



12
13
14
15
# File 'lib/imap/backup/uploader.rb', line 12

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

Instance Method Details

#runvoid

This method returns an undefined value.

Uploads messages that are present in the backup, but not in the online folder



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

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 |message, i|
    upload_message message, i + 1
  end
end