forked from mirror/django-mailbox
handle too many open files case
This commit is contained in:
parent
0be2afdec8
commit
cb9ed0bd21
1 changed files with 15 additions and 13 deletions
|
|
@ -719,10 +719,11 @@ class Message(models.Model):
|
||||||
if encoding and encoding.lower() == 'quoted-printable':
|
if encoding and encoding.lower() == 'quoted-printable':
|
||||||
# Cannot use `email.encoders.encode_quopri due to
|
# Cannot use `email.encoders.encode_quopri due to
|
||||||
# bug 14360: http://bugs.python.org/issue14360
|
# bug 14360: http://bugs.python.org/issue14360
|
||||||
|
with attachment.document.open('rb') as f:
|
||||||
output = BytesIO()
|
output = BytesIO()
|
||||||
encode_quopri(
|
encode_quopri(
|
||||||
BytesIO(
|
BytesIO(
|
||||||
attachment.document.read()
|
f.read()
|
||||||
),
|
),
|
||||||
output,
|
output,
|
||||||
quotetabs=True,
|
quotetabs=True,
|
||||||
|
|
@ -734,7 +735,8 @@ class Message(models.Model):
|
||||||
del new['Content-Transfer-Encoding']
|
del new['Content-Transfer-Encoding']
|
||||||
new['Content-Transfer-Encoding'] = 'quoted-printable'
|
new['Content-Transfer-Encoding'] = 'quoted-printable'
|
||||||
else:
|
else:
|
||||||
new.set_payload(attachment.document.read())
|
with attachment.document.open('rb') as f:
|
||||||
|
new.set_payload(f.read())
|
||||||
del new['Content-Transfer-Encoding']
|
del new['Content-Transfer-Encoding']
|
||||||
encode_base64(new)
|
encode_base64(new)
|
||||||
except MessageAttachment.DoesNotExist:
|
except MessageAttachment.DoesNotExist:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue