From e3c6c635470b0ec79cbd3cb61c386bccd6374594 Mon Sep 17 00:00:00 2001 From: drew Date: Fri, 24 Jul 2026 16:29:19 +0400 Subject: [PATCH 1/2] fix: attatchments not downloaded Signed-off-by: drew --- main.go | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 18a191b3..b6b248eb 100644 --- a/main.go +++ b/main.go @@ -2346,7 +2346,15 @@ func (m *mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { //nolint:gocyclo Encoding: encoding, Mailbox: msg.Mailbox, } - return m, tea.Batch(m.current.Init(), downloadAttachmentCmd(account, email.UID, newMsg)) + // Resolve the actual IMAP folder the email lives in, mirroring the body + // fetch path. Custom folders (Starred, All Mail, Important) report + // Mailbox == MailboxInbox but carry the real name via folderInbox, so + // without this the attachment is fetched from INBOX and fails. + folderName := folderInbox + if m.folderInbox != nil { + folderName = m.folderInbox.GetCurrentFolder() + } + return m, tea.Batch(m.current.Init(), downloadAttachmentCmd(account, email.UID, folderName, newMsg)) case tui.AttachmentDownloadedMsg: var statusMsg string @@ -3603,7 +3611,7 @@ func truncateUTF8(s string, maxBytes int) string { return s } -func downloadAttachmentCmd(account *config.Account, uid uint32, msg tui.DownloadAttachmentMsg) tea.Cmd { +func downloadAttachmentCmd(account *config.Account, uid uint32, folderName string, msg tui.DownloadAttachmentMsg) tea.Cmd { return func() tea.Msg { // Download and decode the attachment using encoding provided in msg.Encoding. var data []byte @@ -3615,8 +3623,14 @@ func downloadAttachmentCmd(account *config.Account, uid uint32, msg tui.Download data, err = fetcher.FetchTrashAttachment(account, uid, msg.PartID, msg.Encoding) case tui.MailboxArchive: data, err = fetcher.FetchArchiveAttachment(account, uid, msg.PartID, msg.Encoding) - case tui.MailboxInbox: - data, err = fetcher.FetchAttachment(account, uid, msg.PartID, msg.Encoding) + default: + // MailboxInbox and any custom folder (Starred, All Mail, Important, ...). + // Select the exact folder the email lives in rather than assuming INBOX. + if folderName != "" { + data, err = fetcher.FetchAttachmentFromMailbox(account, folderName, uid, msg.PartID, msg.Encoding) + } else { + data, err = fetcher.FetchAttachment(account, uid, msg.PartID, msg.Encoding) + } } if err != nil { From f1bed29b95a2760a4da3114a0444fbde28f43afb Mon Sep 17 00:00:00 2001 From: drew Date: Fri, 24 Jul 2026 16:35:17 +0400 Subject: [PATCH 2/2] chore: lint Signed-off-by: drew --- main.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.go b/main.go index b6b248eb..a5248577 100644 --- a/main.go +++ b/main.go @@ -3623,6 +3623,8 @@ func downloadAttachmentCmd(account *config.Account, uid uint32, folderName strin data, err = fetcher.FetchTrashAttachment(account, uid, msg.PartID, msg.Encoding) case tui.MailboxArchive: data, err = fetcher.FetchArchiveAttachment(account, uid, msg.PartID, msg.Encoding) + case tui.MailboxInbox: + fallthrough default: // MailboxInbox and any custom folder (Starred, All Mail, Important, ...). // Select the exact folder the email lives in rather than assuming INBOX.