aboutsummaryrefslogtreecommitdiffstats
path: root/worker/imap
diff options
context:
space:
mode:
Diffstat (limited to 'worker/imap')
-rw-r--r--worker/imap/cache.go30
-rw-r--r--worker/imap/checkmail.go4
-rw-r--r--worker/imap/connect.go8
-rw-r--r--worker/imap/fetch.go12
-rw-r--r--worker/imap/flags.go4
-rw-r--r--worker/imap/idler.go8
-rw-r--r--worker/imap/list.go8
-rw-r--r--worker/imap/observer.go4
-rw-r--r--worker/imap/open.go16
-rw-r--r--worker/imap/worker.go12
10 files changed, 53 insertions, 53 deletions
diff --git a/worker/imap/cache.go b/worker/imap/cache.go
index cf92dfaa..a889f725 100644
--- a/worker/imap/cache.go
+++ b/worker/imap/cache.go
@@ -9,7 +9,7 @@ import (
"path"
"time"
- "git.sr.ht/~rjarry/aerc/logging"
+ "git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/worker/types"
"github.com/emersion/go-message"
@@ -34,18 +34,18 @@ func (w *IMAPWorker) initCacheDb(acct string) {
cd, err := cacheDir()
if err != nil {
w.cache = nil
- logging.Errorf("unable to find cache directory: %v", err)
+ log.Errorf("unable to find cache directory: %v", err)
return
}
p := path.Join(cd, acct)
db, err := leveldb.OpenFile(p, nil)
if err != nil {
w.cache = nil
- logging.Errorf("failed opening cache db: %v", err)
+ log.Errorf("failed opening cache db: %v", err)
return
}
w.cache = db
- logging.Debugf("cache db opened: %s", p)
+ log.Debugf("cache db opened: %s", p)
if w.config.cacheMaxAge.Hours() > 0 {
go w.cleanCache(p)
}
@@ -54,11 +54,11 @@ func (w *IMAPWorker) initCacheDb(acct string) {
func (w *IMAPWorker) cacheHeader(mi *models.MessageInfo) {
uv := fmt.Sprintf("%d", w.selected.UidValidity)
uid := fmt.Sprintf("%d", mi.Uid)
- logging.Debugf("caching header for message %s.%s", uv, uid)
+ log.Debugf("caching header for message %s.%s", uv, uid)
hdr := bytes.NewBuffer(nil)
err := textproto.WriteHeader(hdr, mi.RFC822Headers.Header.Header)
if err != nil {
- logging.Errorf("cannot write header %s.%s: %v", uv, uid, err)
+ log.Errorf("cannot write header %s.%s: %v", uv, uid, err)
return
}
h := &CachedHeader{
@@ -73,18 +73,18 @@ func (w *IMAPWorker) cacheHeader(mi *models.MessageInfo) {
enc := gob.NewEncoder(data)
err = enc.Encode(h)
if err != nil {
- logging.Errorf("cannot encode message %s.%s: %v", uv, uid, err)
+ log.Errorf("cannot encode message %s.%s: %v", uv, uid, err)
return
}
err = w.cache.Put([]byte("header."+uv+"."+uid), data.Bytes(), nil)
if err != nil {
- logging.Errorf("cannot write header for message %s.%s: %v", uv, uid, err)
+ log.Errorf("cannot write header for message %s.%s: %v", uv, uid, err)
return
}
}
func (w *IMAPWorker) getCachedHeaders(msg *types.FetchMessageHeaders) []uint32 {
- logging.Tracef("Retrieving headers from cache: %v", msg.Uids)
+ log.Tracef("Retrieving headers from cache: %v", msg.Uids)
var need []uint32
uv := fmt.Sprintf("%d", w.selected.UidValidity)
for _, uid := range msg.Uids {
@@ -98,14 +98,14 @@ func (w *IMAPWorker) getCachedHeaders(msg *types.FetchMessageHeaders) []uint32 {
dec := gob.NewDecoder(bytes.NewReader(data))
err = dec.Decode(ch)
if err != nil {
- logging.Errorf("cannot decode cached header %s.%s: %v", uv, u, err)
+ log.Errorf("cannot decode cached header %s.%s: %v", uv, u, err)
need = append(need, uid)
continue
}
hr := bytes.NewReader(ch.Header)
textprotoHeader, err := textproto.ReadHeader(bufio.NewReader(hr))
if err != nil {
- logging.Errorf("cannot read cached header %s.%s: %v", uv, u, err)
+ log.Errorf("cannot read cached header %s.%s: %v", uv, u, err)
need = append(need, uid)
continue
}
@@ -122,7 +122,7 @@ func (w *IMAPWorker) getCachedHeaders(msg *types.FetchMessageHeaders) []uint32 {
if err != nil {
mi.Refs = refs
}
- logging.Tracef("located cached header %s.%s", uv, u)
+ log.Tracef("located cached header %s.%s", uv, u)
w.worker.PostMessage(&types.MessageInfo{
Message: types.RespondTo(msg),
Info: mi,
@@ -154,14 +154,14 @@ func (w *IMAPWorker) cleanCache(path string) {
dec := gob.NewDecoder(bytes.NewReader(data))
err := dec.Decode(ch)
if err != nil {
- logging.Errorf("cannot clean database %d: %v", w.selected.UidValidity, err)
+ log.Errorf("cannot clean database %d: %v", w.selected.UidValidity, err)
continue
}
exp := ch.Created.Add(w.config.cacheMaxAge)
if exp.Before(time.Now()) {
err = w.cache.Delete(iter.Key(), nil)
if err != nil {
- logging.Errorf("cannot clean database %d: %v", w.selected.UidValidity, err)
+ log.Errorf("cannot clean database %d: %v", w.selected.UidValidity, err)
continue
}
removed++
@@ -170,6 +170,6 @@ func (w *IMAPWorker) cleanCache(path string) {
}
iter.Release()
elapsed := time.Since(start)
- logging.Debugf("%s: removed %d/%d expired entries in %s",
+ log.Debugf("%s: removed %d/%d expired entries in %s",
path, removed, scanned, elapsed)
}
diff --git a/worker/imap/checkmail.go b/worker/imap/checkmail.go
index 0f347e09..34cf63d1 100644
--- a/worker/imap/checkmail.go
+++ b/worker/imap/checkmail.go
@@ -1,7 +1,7 @@
package imap
import (
- "git.sr.ht/~rjarry/aerc/logging"
+ "git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/worker/types"
"github.com/emersion/go-imap"
@@ -20,7 +20,7 @@ func (w *IMAPWorker) handleCheckMailMessage(msg *types.CheckMail) {
continue
}
- logging.Tracef("Getting status of directory %s", dir)
+ log.Tracef("Getting status of directory %s", dir)
status, err := w.client.Status(dir, items)
if err != nil {
w.worker.PostMessage(&types.Error{
diff --git a/worker/imap/connect.go b/worker/imap/connect.go
index 035feaba..d6c946db 100644
--- a/worker/imap/connect.go
+++ b/worker/imap/connect.go
@@ -7,7 +7,7 @@ import (
"time"
"git.sr.ht/~rjarry/aerc/lib"
- "git.sr.ht/~rjarry/aerc/logging"
+ "git.sr.ht/~rjarry/aerc/log"
"github.com/emersion/go-imap"
"github.com/emersion/go-imap/client"
)
@@ -66,7 +66,7 @@ func (w *IMAPWorker) connect() (*client.Client, error) {
return nil, fmt.Errorf("Unknown IMAP scheme %s", w.config.scheme)
}
- c.ErrorLog = logging.ErrorLogger()
+ c.ErrorLog = log.ErrorLogger()
if w.config.user != nil {
username := w.config.user.Username()
@@ -165,12 +165,12 @@ func (w *IMAPWorker) setKeepaliveParameters(conn *net.TCPConn) error {
// Max number of probes before failure
err := lib.SetTcpKeepaliveProbes(fd, w.config.keepalive_probes)
if err != nil {
- logging.Errorf("cannot set tcp keepalive probes: %v", err)
+ log.Errorf("cannot set tcp keepalive probes: %v", err)
}
// Wait time after an unsuccessful probe
err = lib.SetTcpKeepaliveInterval(fd, w.config.keepalive_interval)
if err != nil {
- logging.Errorf("cannot set tcp keepalive interval: %v", err)
+ log.Errorf("cannot set tcp keepalive interval: %v", err)
}
})
return err
diff --git a/worker/imap/fetch.go b/worker/imap/fetch.go
index 9256c6eb..62451308 100644
--- a/worker/imap/fetch.go
+++ b/worker/imap/fetch.go
@@ -10,7 +10,7 @@ import (
"github.com/emersion/go-message/mail"
"github.com/emersion/go-message/textproto"
- "git.sr.ht/~rjarry/aerc/logging"
+ "git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/worker/types"
)
@@ -27,7 +27,7 @@ func (imapw *IMAPWorker) handleFetchMessageHeaders(
nil)
return
}
- logging.Tracef("Fetching message headers: %v", toFetch)
+ log.Tracef("Fetching message headers: %v", toFetch)
section := &imap.BodySectionName{
BodyPartName: imap.BodyPartName{
Specifier: imap.HeaderSpecifier,
@@ -84,7 +84,7 @@ func (imapw *IMAPWorker) handleFetchMessageHeaders(
func (imapw *IMAPWorker) handleFetchMessageBodyPart(
msg *types.FetchMessageBodyPart,
) {
- logging.Tracef("Fetching message %d part: %v", msg.Uid, msg.Part)
+ log.Tracef("Fetching message %d part: %v", msg.Uid, msg.Part)
var partHeaderSection imap.BodySectionName
partHeaderSection.Peek = true
@@ -130,7 +130,7 @@ func (imapw *IMAPWorker) handleFetchMessageBodyPart(
part, err := message.New(message.Header{Header: h},
_msg.GetBody(&partBodySection))
if message.IsUnknownCharset(err) {
- logging.Warnf("unknown charset encountered "+
+ log.Warnf("unknown charset encountered "+
"for uid %d", _msg.Uid)
} else if err != nil {
return fmt.Errorf("failed to create message reader: %w", err)
@@ -158,7 +158,7 @@ func (imapw *IMAPWorker) handleFetchMessageBodyPart(
func (imapw *IMAPWorker) handleFetchFullMessages(
msg *types.FetchFullMessages,
) {
- logging.Tracef("Fetching full messages: %v", msg.Uids)
+ log.Tracef("Fetching full messages: %v", msg.Uids)
section := &imap.BodySectionName{
Peek: true,
}
@@ -223,7 +223,7 @@ func (imapw *IMAPWorker) handleFetchMessages(
done := make(chan error)
go func() {
- defer logging.PanicHandler()
+ defer log.PanicHandler()
var reterr error
for _msg := range messages {
diff --git a/worker/imap/flags.go b/worker/imap/flags.go
index 7ff6de37..9d9ecc86 100644
--- a/worker/imap/flags.go
+++ b/worker/imap/flags.go
@@ -3,7 +3,7 @@ package imap
import (
"github.com/emersion/go-imap"
- "git.sr.ht/~rjarry/aerc/logging"
+ "git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/worker/types"
)
@@ -76,7 +76,7 @@ func (imapw *IMAPWorker) handleStoreOps(
done := make(chan error)
go func() {
- defer logging.PanicHandler()
+ defer log.PanicHandler()
var reterr error
for _msg := range messages {
diff --git a/worker/imap/idler.go b/worker/imap/idler.go
index da018334..d099ee88 100644
--- a/worker/imap/idler.go
+++ b/worker/imap/idler.go
@@ -5,7 +5,7 @@ import (
"sync"
"time"
- "git.sr.ht/~rjarry/aerc/logging"
+ "git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/worker/types"
"github.com/emersion/go-imap"
"github.com/emersion/go-imap/client"
@@ -78,7 +78,7 @@ func (i *idler) Start() {
i.stop = make(chan struct{})
go func() {
- defer logging.PanicHandler()
+ defer log.PanicHandler()
select {
case <-i.stop:
// debounce idle
@@ -146,7 +146,7 @@ func (i *idler) waitOnIdle() {
i.setWaiting(true)
i.log("wait for idle in background")
go func() {
- defer logging.PanicHandler()
+ defer log.PanicHandler()
err := <-i.done
if err == nil {
i.log("<=(idle) waited")
@@ -166,5 +166,5 @@ func (i *idler) waitOnIdle() {
func (i *idler) log(format string, v ...interface{}) {
msg := fmt.Sprintf(format, v...)
- logging.Tracef("idler (%p) [idle:%t,wait:%t] %s", i, i.isIdleing(), i.isWaiting(), msg)
+ log.Tracef("idler (%p) [idle:%t,wait:%t] %s", i, i.isIdleing(), i.isWaiting(), msg)
}
diff --git a/worker/imap/list.go b/worker/imap/list.go
index c3211f21..e02d7cbb 100644
--- a/worker/imap/list.go
+++ b/worker/imap/list.go
@@ -3,18 +3,18 @@ package imap
import (
"github.com/emersion/go-imap"
- "git.sr.ht/~rjarry/aerc/logging"
+ "git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/worker/types"
)
func (imapw *IMAPWorker) handleListDirectories(msg *types.ListDirectories) {
mailboxes := make(chan *imap.MailboxInfo)
- logging.Tracef("Listing mailboxes")
+ log.Tracef("Listing mailboxes")
done := make(chan interface{})
go func() {
- defer logging.PanicHandler()
+ defer log.PanicHandler()
for mbox := range mailboxes {
if !canOpen(mbox) {
@@ -62,7 +62,7 @@ func (imapw *IMAPWorker) handleSearchDirectory(msg *types.SearchDirectory) {
}, nil)
}
- logging.Tracef("Executing search")
+ log.Tracef("Executing search")
criteria, err := parseSearch(msg.Argv)
if err != nil {
emitError(err)
diff --git a/worker/imap/observer.go b/worker/imap/observer.go
index 867b57d9..2cfe8bd9 100644
--- a/worker/imap/observer.go
+++ b/worker/imap/observer.go
@@ -6,7 +6,7 @@ import (
"sync"
"time"
- "git.sr.ht/~rjarry/aerc/logging"
+ "git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/worker/types"
"github.com/emersion/go-imap"
)
@@ -150,5 +150,5 @@ func (o *observer) emit(errMsg string) {
func (o *observer) log(format string, args ...interface{}) {
msg := fmt.Sprintf(format, args...)
- logging.Tracef("observer (%p) [running:%t] %s", o, o.running, msg)
+ log.Tracef("observer (%p) [running:%t] %s", o, o.running, msg)
}
diff --git a/worker/imap/open.go b/worker/imap/open.go
index f554d524..ced307be 100644
--- a/worker/imap/open.go
+++ b/worker/imap/open.go
@@ -5,12 +5,12 @@ import (
sortthread "github.com/emersion/go-imap-sortthread"
- "git.sr.ht/~rjarry/aerc/logging"
+ "git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/worker/types"
)
func (imapw *IMAPWorker) handleOpenDirectory(msg *types.OpenDirectory) {
- logging.Debugf("Opening %s", msg.Directory)
+ log.Debugf("Opening %s", msg.Directory)
sel, err := imapw.client.Select(msg.Directory, false)
if err != nil {
@@ -27,7 +27,7 @@ func (imapw *IMAPWorker) handleOpenDirectory(msg *types.OpenDirectory) {
func (imapw *IMAPWorker) handleFetchDirectoryContents(
msg *types.FetchDirectoryContents,
) {
- logging.Tracef("Fetching UID list")
+ log.Tracef("Fetching UID list")
searchCriteria, err := parseSearch(msg.FilterCriteria)
if err != nil {
@@ -52,9 +52,9 @@ func (imapw *IMAPWorker) handleFetchDirectoryContents(
} else {
if err != nil {
// Non fatal, but we do want to print to get some debug info
- logging.Errorf("can't check for SORT support: %v", err)
+ log.Errorf("can't check for SORT support: %v", err)
} else if len(sortCriteria) > 0 {
- logging.Warnf("SORT is not supported but requested: list messages by UID")
+ log.Warnf("SORT is not supported but requested: list messages by UID")
}
uids, err = imapw.client.UidSearch(searchCriteria)
}
@@ -64,7 +64,7 @@ func (imapw *IMAPWorker) handleFetchDirectoryContents(
Error: err,
}, nil)
} else {
- logging.Tracef("Found %d UIDs", len(uids))
+ log.Tracef("Found %d UIDs", len(uids))
if len(msg.FilterCriteria) == 1 {
// Only initialize if we are not filtering
imapw.seqMap.Initialize(uids)
@@ -105,7 +105,7 @@ func translateSortCriterions(
func (imapw *IMAPWorker) handleDirectoryThreaded(
msg *types.FetchDirectoryThreaded,
) {
- logging.Tracef("Fetching threaded UID list")
+ log.Tracef("Fetching threaded UID list")
searchCriteria, err := parseSearch(msg.FilterCriteria)
if err != nil {
@@ -125,7 +125,7 @@ func (imapw *IMAPWorker) handleDirectoryThreaded(
} else {
aercThreads, count := convertThreads(threads, nil)
sort.Sort(types.ByUID(aercThreads))
- logging.Tracef("Found %d threaded messages", count)
+ log.Tracef("Found %d threaded messages", count)
if len(msg.FilterCriteria) == 1 {
// Only initialize if we are not filtering
var uids []uint32
diff --git a/worker/imap/worker.go b/worker/imap/worker.go
index c3021f91..32e05859 100644
--- a/worker/imap/worker.go
+++ b/worker/imap/worker.go
@@ -12,7 +12,7 @@ import (
"github.com/syndtr/goleveldb/leveldb"
"git.sr.ht/~rjarry/aerc/lib"
- "git.sr.ht/~rjarry/aerc/logging"
+ "git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/worker/handlers"
"git.sr.ht/~rjarry/aerc/worker/types"
@@ -93,14 +93,14 @@ func (w *IMAPWorker) newClient(c *client.Client) {
sort, err := w.client.sort.SupportSort()
if err == nil && sort {
w.caps.Sort = true
- logging.Debugf("Server Capability found: Sort")
+ log.Debugf("Server Capability found: Sort")
}
for _, alg := range []sortthread.ThreadAlgorithm{sortthread.References, sortthread.OrderedSubject} {
ok, err := w.client.Support(fmt.Sprintf("THREAD=%s", string(alg)))
if err == nil && ok {
w.threadAlgorithm = alg
w.caps.Thread = true
- logging.Debugf("Server Capability found: Thread (algorithm: %s)", string(alg))
+ log.Debugf("Server Capability found: Thread (algorithm: %s)", string(alg))
break
}
}
@@ -233,7 +233,7 @@ func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error {
}
func (w *IMAPWorker) handleImapUpdate(update client.Update) {
- logging.Tracef("(= %T", update)
+ log.Tracef("(= %T", update)
switch update := update.(type) {
case *client.MailboxUpdate:
status := update.Mailbox
@@ -256,7 +256,7 @@ func (w *IMAPWorker) handleImapUpdate(update client.Update) {
msg := update.Message
if msg.Uid == 0 {
if uid, found := w.seqMap.Get(msg.SeqNum); !found {
- logging.Errorf("MessageUpdate unknown seqnum: %d", msg.SeqNum)
+ log.Errorf("MessageUpdate unknown seqnum: %d", msg.SeqNum)
return
} else {
msg.Uid = uid
@@ -276,7 +276,7 @@ func (w *IMAPWorker) handleImapUpdate(update client.Update) {
}, nil)
case *client.ExpungeUpdate:
if uid, found := w.seqMap.Pop(update.SeqNum); !found {
- logging.Errorf("ExpungeUpdate unknown seqnum: %d", update.SeqNum)
+ log.Errorf("ExpungeUpdate unknown seqnum: %d", update.SeqNum)
} else {
w.worker.PostMessage(&types.MessagesDeleted{
Uids: []uint32{uid},