Class: Imap::Backup::Downloader
- Inherits:
-
Object
- Object
- Imap::Backup::Downloader
- Defined in:
- lib/imap/backup/downloader.rb
Defined Under Namespace
Classes: MultiFetchFailedError
Instance Method Summary collapse
-
#initialize(folder, serializer, multi_fetch_size: 1, reset_seen_flags_after_fetch: false) ⇒ Downloader
constructor
A new instance of Downloader.
- #run ⇒ Object
Constructor Details
#initialize(folder, serializer, multi_fetch_size: 1, reset_seen_flags_after_fetch: false) ⇒ Downloader
Returns a new instance of Downloader.
9 10 11 12 13 14 15 |
# File 'lib/imap/backup/downloader.rb', line 9 def initialize(folder, serializer, multi_fetch_size: 1, reset_seen_flags_after_fetch: false) @folder = folder @serializer = serializer @multi_fetch_size = multi_fetch_size @reset_seen_flags_after_fetch = reset_seen_flags_after_fetch @uids = nil end |
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/imap/backup/downloader.rb', line 17 def run info("#{uids.count} new messages") if uids.any? uids.each_slice(multi_fetch_size).with_index do |block, i| multifetch_failed = download_block(block, i) raise MultiFetchFailedError if multifetch_failed end rescue MultiFetchFailedError @count = nil @multi_fetch_size = 1 @uids = nil retry rescue Net::IMAP::ByeResponseError folder.client.reconnect retry end |