Add body read timeout recovery to IMAP client

Introduce Client wrapper with socket deadline support
Add reconnection logic for body read timeouts
Implement test cases for underflow scenarios
Update orchestrator to handle reconnections
This commit is contained in:
2026-07-21 05:29:35 +07:00
parent c741cd19a0
commit 6bf3a6c4ca
6 changed files with 375 additions and 30 deletions
+2 -3
View File
@@ -4,13 +4,12 @@ import (
"context"
"github.com/emersion/go-imap/v2"
"github.com/emersion/go-imap/v2/imapclient"
)
// FolderMessageCount opens a folder read-only (EXAMINE) and returns how many
// messages it holds — used to plan an accurate overall progress total before
// copying begins. It does not fetch any message bodies.
func FolderMessageCount(c *imapclient.Client, folder string) (int64, error) {
func FolderMessageCount(c *Client, folder string) (int64, error) {
sel, err := c.Select(folder, &imap.SelectOptions{ReadOnly: true}).Wait()
if err != nil {
return 0, err
@@ -19,7 +18,7 @@ func FolderMessageCount(c *imapclient.Client, folder string) (int64, error) {
}
// ListFolders returns the mailbox names visible on an already-connected, logged-in client.
func ListFolders(c *imapclient.Client) ([]string, error) {
func ListFolders(c *Client) ([]string, error) {
mboxes, err := c.List("", "*", nil).Collect()
if err != nil {
return nil, err