summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2012-02-08 09:28:46 +0000
committerPatrick Totzke <patricktotzke@gmail.com>2012-02-08 09:28:46 +0000
commit08a1865b3a2ba8f59f7f2e1e7ce9ce83842a242f (patch)
tree38a2bf30094516102e657410d9e0f2420ae10727
parent1a022c775a6e9516521035a08c4e22427919858d (diff)
sane fall back for guess_mimetyped
helper.guess_mimetype is expected to return a mimetype string. If libmagic fails it used to return None. This makes it fall back to 'application/octet-stream'. close #313
-rw-r--r--alot/helper.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/alot/helper.py b/alot/helper.py
index f14c2c94..6fc3a970 100644
--- a/alot/helper.py
+++ b/alot/helper.py
@@ -307,11 +307,12 @@ def guess_mimetype(blob):
:param blob: file content as read by file.read()
:type blob: data
- :returns: mime-type
+ :returns: mime-type, falls back to 'application/octet-stream'
+ :rtype: str
"""
m = magic.open(magic.MAGIC_MIME_TYPE)
m.load()
- return m.buffer(blob)
+ return m.buffer(blob) or 'application/octet-stream'
def guess_encoding(blob):