Class: Imap::Backup::Serializer::Appender
- Inherits:
-
Object
- Object
- Imap::Backup::Serializer::Appender
- Defined in:
- lib/imap/backup/serializer/appender.rb
Instance Attribute Summary collapse
-
#folder ⇒ Object
readonly
Returns the value of attribute folder.
-
#imap ⇒ Object
readonly
Returns the value of attribute imap.
-
#mbox ⇒ Object
readonly
Returns the value of attribute mbox.
Instance Method Summary collapse
- #append(uid:, message:, flags:) ⇒ Object
-
#initialize(folder:, imap:, mbox:) ⇒ Appender
constructor
A new instance of Appender.
Constructor Details
#initialize(folder:, imap:, mbox:) ⇒ Appender
Returns a new instance of Appender.
13 14 15 16 17 |
# File 'lib/imap/backup/serializer/appender.rb', line 13 def initialize(folder:, imap:, mbox:) @folder = folder @imap = imap @mbox = mbox end |
Instance Attribute Details
#folder ⇒ Object (readonly)
Returns the value of attribute folder.
10 11 12 |
# File 'lib/imap/backup/serializer/appender.rb', line 10 def folder @folder end |
#imap ⇒ Object (readonly)
Returns the value of attribute imap.
9 10 11 |
# File 'lib/imap/backup/serializer/appender.rb', line 9 def imap @imap end |
#mbox ⇒ Object (readonly)
Returns the value of attribute mbox.
11 12 13 |
# File 'lib/imap/backup/serializer/appender.rb', line 11 def mbox @mbox end |
Instance Method Details
#append(uid:, message:, flags:) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/imap/backup/serializer/appender.rb', line 19 def append(uid:, message:, flags:) raise "Can't add messages without uid_validity" if !imap.uid_validity uid = uid.to_i existing = imap.get(uid) if existing Logger.logger.debug( "[#{folder}] message #{uid} already downloaded - skipping" ) return end rollback_on_error do serialized = to_serialized() mbox.append serialized imap.append uid, serialized.bytesize, flags: flags rescue StandardError => e raise " [\#{folder}] failed to append message \#{uid}: \#{message}.\n \#{e}:\n \#{e.backtrace.join(\"\\n\")}\"\n ERROR\n end\nend\n".gsub(/^\s*/m, "") |