Skip to content

Commit

Permalink
Handle cases where a MIME part is a string instead of a Message.
Browse files Browse the repository at this point in the history
Reduced the verbosity of a part reassembly error due to a missing file.
  • Loading branch information
ahknight committed May 2, 2016
1 parent 0e95434 commit f799e42
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions emlx/mailbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ def load_parts(message, prefix):
for part in parts:
partno = parts.index(part) + 1

if type(part) is str:
continue

if part.is_multipart():
load_parts(part, "%s.%d" % (prefix, partno))

Expand All @@ -107,7 +110,7 @@ def load_parts(message, prefix):
parts_loaded +=1

except Exception as e:
logging.exception("%s: error loading message part %d" % (path, partno))
logging.error("%s: error loading message part %d" % (path, partno))

if parts_loaded != parts_needed:
logging.warning("%s: message may be incomplete (found %d parts of %d)" % (
Expand All @@ -127,7 +130,12 @@ def load_parts(message, prefix):

return msg


# There are three types of mailboxes:
# 1. The type used by the app for daily operation. This has a trie system for storage and keeps messages in a folder called Messages at the bottom.
# 2. An export format where the mbox directory contains a mbox file and a TOC. This file is a standard mailspool file and should be read as such and not modified.
# 3. An older format where the emlx files are a flat list inside the mbox directory.
#
# Currently, this handles only the first format. It should handle them all.
class AMMailbox(object):
parent = None
path = None
Expand Down

0 comments on commit f799e42

Please sign in to comment.