From 0cba695454666d665d6070a02f0fb7698bd02138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rafael=20Silva=20Hermoso?= <56702181+joserafaelSH@users.noreply.github.com> Date: Tue, 28 Apr 2026 04:33:24 -0300 Subject: [PATCH] fix(cache): add log email cache errors (#1181) ## What? Added error handling and logging to email body caching operations in `main.go`. Previously, `config.SaveEmailBody()` calls were ignoring errors with `_`, now they capture and log failures for both synchronous and asynchronous caching scenarios. ## Why? Email body caching could fail silently due to disk full or permission denied errors, making debugging difficult when users experienced missing cached emails. This change adds visibility into caching failures to help diagnose storage-related issues. closes: #1030 --- main.go | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 4462c38f7c3567c6f9eeb186a9d7bda594ec64df..ad0d8537c06f74bd453cd7388662aae1fc70da0d 100644 --- a/main.go +++ b/main.go @@ -733,12 +733,17 @@ func (m *mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { Inline: a.Inline, }) } - go config.SaveEmailBody(folderName, config.CachedEmailBody{ - UID: msg.UID, - AccountID: msg.AccountID, - Body: msg.Body, - Attachments: cachedAttachments, - }) + go func() { + err := config.SaveEmailBody(folderName, config.CachedEmailBody{ + UID: msg.UID, + AccountID: msg.AccountID, + Body: msg.Body, + Attachments: cachedAttachments, + }) + if err != nil { + log.Printf("debug: error caching email body fails (disk full, permission denied) for UID: %d: %v", msg.UID, err) + } + }() } // Forward to FolderInbox for rendering if m.folderInbox != nil { @@ -1260,13 +1265,17 @@ func (m *mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } cachedAttachments = append(cachedAttachments, ca) } - _ = config.SaveEmailBody(folderForCache, config.CachedEmailBody{ + err := config.SaveEmailBody(folderForCache, config.CachedEmailBody{ UID: msg.UID, AccountID: msg.AccountID, Body: msg.Body, Attachments: cachedAttachments, }) + if err != nil { + log.Printf("debug: error caching email body fails (disk full, permission denied) for UID: %d: %v", msg.UID, err) + } + email := m.getEmailByUIDAndAccount(msg.UID, msg.AccountID, msg.Mailbox) if email == nil { if m.folderInbox != nil {