Repository navigation
Download only the parts a tool uses - #48
Merged
Merged
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c82b077726
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
SwiftMail's fetchMessages(using:) downloads every part of a message, attachments included. Listing, post fetch, attachment downloads and PDF export all went through it, so listing a folder or reading the text of an email with a 77 MB video downloaded the video. - listMessages fetches header data only, on an extra connection like search. - fetchMessage and exportPDF fetch the structure, then only the text and HTML bodies; attachments are still listed by name and type. - downloadAttachment picks the part from the structure and downloads only that part. LeanFetchLiveTests compares the results with full downloads on a real account; it runs only with POST_LIVE_TEST_SERVER set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fetchMessage expanded the requested UID set into an array and fetched it 200 UIDs at a time, so a range like 1-1000000 meant a million-element array and 5,000 FETCH commands. It now sends the set as given in one UID FETCH, and the server answers only for messages that exist. SwiftMail's fetchMessages expanded such ranges as well, in chunked(size:). The header fetch uses SwiftMail's default info set, which includes the full header section, so additional headers are still filled. The doc comment that said otherwise is corrected; the live test now compares additional headers too and fetches a wide range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
odrobnik
force-pushed
the
claude/lean-fetch
branch
from
October 7, 2026 16:36
f729cfd to
adb85fb
Compare
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.
Stacked on #47 (base
claude/imap-connection-race): it reuses #47's header-only fetch and extra connections. Merge #47 first; GitHub then retargets this PR tomain.Problem
SwiftMail's
fetchMessages(using:)fetches each message's structure and then every part, attachments included. Four tools went through it although none of them uses attachment data:listMessages(post list) only shows header data,fetchMessage(post fetchwithout--eml) shows the text and HTML bodies and lists attachments by name and type,exportPDF(post pdf) renders the text or HTML body,downloadAttachment(post attachment) needs one part.So listing a folder, or reading an email with a 77 MB video attached, downloaded the video.
Fix
listMessagesfetches header data only (fetchMessageInfosBulk, in chunks of 200) and runs on an extra connection, like search.fetchMessageandexportPDFstart from the message's outline (header data plus structure,fetchOutline) and download onlyMessage.bodies(downloading(_:of:uid:using:)). Attachments are still listed from the structure.downloadAttachmentchooses the part (bycid, by filename, or the first attachment) from the outline and downloads only that part. Errors are unchanged.collectHeaders(from:)is gone; nothing uses it any more.Tests
swift test: 61 tests, 0 failures (3 live tests skipped without credentials).LeanFetchLiveTests(read-only; runs only withPOST_LIVE_TEST_SERVER): compares the listing andfetchMessageresults for the newest 8 messages with full downloads, and a downloaded attachment with the full download's part (POST_LIVE_TEST_ATTACHMENT=<mailbox>:<uid>). Passed on two accounts' INBOX and Sent and on a PDF attachment.ConcurrentMailboxAccessLiveTestsfrom Stop concurrent requests from running in each other's mailbox #47, which now also exercises the listing on an extra connection, still passes.🤖 Generated with Claude Code