Class: Imap::Backup::Serializer::IntegrityChecker
- Inherits:
-
Object
- Object
- Imap::Backup::Serializer::IntegrityChecker
- Defined in:
- lib/imap/backup/serializer/integrity_checker.rb
Overview
Checks that both the mailbox and its associated metadata file match
Instance Method Summary collapse
-
#initialize(imap:, mbox:) ⇒ IntegrityChecker
constructor
A new instance of IntegrityChecker.
-
#run ⇒ void
Runs the integrity check.
Constructor Details
#initialize(imap:, mbox:) ⇒ IntegrityChecker
Returns a new instance of IntegrityChecker.
13 14 15 16 |
# File 'lib/imap/backup/serializer/integrity_checker.rb', line 13 def initialize(imap:, mbox:) @imap = imap @mbox = mbox end |
Instance Method Details
#run ⇒ void
This method returns an undefined value.
Runs the integrity check
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/imap/backup/serializer/integrity_checker.rb', line 22 def run Logger.logger.debug( "[IntegrityChecker] checking '#{imap.pathname}' against '#{mbox.pathname}'" ) if !imap.valid? = ".imap file '#{imap.pathname}' is corrupt" raise Serializer::FolderIntegrityError, end if !mbox.exist? = ".mbox file '#{mbox.pathname}' is missing" raise Serializer::FolderIntegrityError, end if imap..empty? if mbox.length.positive? = ".imap file '#{imap.pathname}' lists no messages, " \ "but .mbox file '#{mbox.pathname}' is not empty" raise Serializer::FolderIntegrityError, end return end check_offset_ordering! check_mbox_length! nil end |