Sha256: f58b13ab4b9a9447f5a1f1f3c29ade606cb1b3cc54143240c9dbd6b65f4cbce2

Contents?: true

Size: 649 Bytes

Versions: 17

Compression:

Stored size: 649 Bytes

Contents

module Imap::Backup
  class FlagRefresher
    attr_reader :folder
    attr_reader :serializer

    CHUNK_SIZE = 100

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

    def run
      uids = serializer.uids.clone

      uids.each_slice(CHUNK_SIZE) do |block|
        refresh_block block
      end
    end

    private

    def refresh_block(uids)
      uids_and_flags = folder.fetch_multi(uids, ["FLAGS"])
      uids_and_flags.each do |uid_and_flags|
        uid = uid_and_flags[:uid]
        flags = uid_and_flags[:flags]
        serializer.update(uid, flags: flags)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
imap-backup-10.0.0 lib/imap/backup/flag_refresher.rb
imap-backup-9.3.2 lib/imap/backup/flag_refresher.rb
imap-backup-9.4.0.pre1 lib/imap/backup/flag_refresher.rb
imap-backup-9.3.1 lib/imap/backup/flag_refresher.rb
imap-backup-9.3.0 lib/imap/backup/flag_refresher.rb
imap-backup-9.2.0 lib/imap/backup/flag_refresher.rb
imap-backup-9.1.1 lib/imap/backup/flag_refresher.rb
imap-backup-9.1.0 lib/imap/backup/flag_refresher.rb
imap-backup-9.0.2 lib/imap/backup/flag_refresher.rb
imap-backup-9.0.1.rc1 lib/imap/backup/flag_refresher.rb
imap-backup-9.0.0 lib/imap/backup/flag_refresher.rb
imap-backup-9.0.0.rc1 lib/imap/backup/flag_refresher.rb
imap-backup-8.0.2 lib/imap/backup/flag_refresher.rb
imap-backup-8.0.1 lib/imap/backup/flag_refresher.rb
imap-backup-8.0.0 lib/imap/backup/flag_refresher.rb
imap-backup-8.0.0.rc1 lib/imap/backup/flag_refresher.rb
imap-backup-7.0.2 lib/imap/backup/flag_refresher.rb