Skip to content

Commit 0cba695

Browse files
authored
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
1 parent b8f1930 commit 0cba695

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

main.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -733,12 +733,17 @@ func (m *mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
733733
Inline: a.Inline,
734734
})
735735
}
736-
go config.SaveEmailBody(folderName, config.CachedEmailBody{
737-
UID: msg.UID,
738-
AccountID: msg.AccountID,
739-
Body: msg.Body,
740-
Attachments: cachedAttachments,
741-
})
736+
go func() {
737+
err := config.SaveEmailBody(folderName, config.CachedEmailBody{
738+
UID: msg.UID,
739+
AccountID: msg.AccountID,
740+
Body: msg.Body,
741+
Attachments: cachedAttachments,
742+
})
743+
if err != nil {
744+
log.Printf("debug: error caching email body fails (disk full, permission denied) for UID: %d: %v", msg.UID, err)
745+
}
746+
}()
742747
}
743748
// Forward to FolderInbox for rendering
744749
if m.folderInbox != nil {
@@ -1260,13 +1265,17 @@ func (m *mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
12601265
}
12611266
cachedAttachments = append(cachedAttachments, ca)
12621267
}
1263-
_ = config.SaveEmailBody(folderForCache, config.CachedEmailBody{
1268+
err := config.SaveEmailBody(folderForCache, config.CachedEmailBody{
12641269
UID: msg.UID,
12651270
AccountID: msg.AccountID,
12661271
Body: msg.Body,
12671272
Attachments: cachedAttachments,
12681273
})
12691274

1275+
if err != nil {
1276+
log.Printf("debug: error caching email body fails (disk full, permission denied) for UID: %d: %v", msg.UID, err)
1277+
}
1278+
12701279
email := m.getEmailByUIDAndAccount(msg.UID, msg.AccountID, msg.Mailbox)
12711280
if email == nil {
12721281
if m.folderInbox != nil {

0 commit comments

Comments
 (0)