Repository navigation
Conversation
The attachment payload was copied into the intermediate RFC 822 message but only the filename and MIME type are ever read. Pass an empty payload instead. Output is unchanged. Signed-off-by: Christer Dreierstad <christerdr@outlook.com>
Contributor
|
✅ DCO Check Passed Thanks @chdre, all your commits are properly signed off. 🎉 |
Contributor
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
Contributor
AI triage (advisory)Checked commit This pull request avoids copying attachment file bytes when Topic labels added: CI safety: no concern found. A maintainer must still approve CI. The |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
EmailDocumentBackend._msg_to_rfc822_bytesconverts an Outlook.msginto an RFC 822 message and copies every attachment's bytes into it. The backend only ever reads the filename and MIME type of attachments, so the copy is wasted. The attachment content is held in memory several times: in the.msgobject, in theEmailMessage, as the serialized bytes, and as the parsed message.This change passes an empty payload to
add_attachmentand keeps the filename and MIME type. Output is unchanged,list_attachmentsstill works, and no new option is added.Checklist
Review evidence
Measured with a full
DocumentConverterconversion of a 60 MB.msgwith one large attachment,list_attachmentson, median of 3, tracemalloc, Windows, Intel Core Ultra 9 285HX. The file is private and not part of the PR.With
list_attachmentsoff, peak memory is also 723.1 MB before and 185.9 MB after, with identical output.New tests in
tests/test_backend_email.py:test_msg_to_rfc822_keeps_attachment_metadata_without_payload: filenames and content types remain, and neither the raw payload nor its base64 form is in the output. It fails on main.test_msg_attachment_listing_leaves_the_body_unchanged_end_to_end: the body text is the same with listing on and off, and the listed attachments are still correct.Commands run:
uv run pytest tests/test_backend_email.py: 29 passed.uv run prek run --files ...: all hooks passed.Not run:
Not included:
.msgfiles with embedded message attachments were not tested.