aboutsummaryrefslogtreecommitdiffstats
path: root/worker/maildir/worker.go
diff options
context:
space:
mode:
authorJulian Pidancet <julian.pidancet@oracle.com>2022-10-26 22:29:03 +0200
committerRobin Jarry <robin@jarry.cc>2022-10-27 21:39:41 +0200
commitea10b329ddd18573fdb066a1a3293c839d839fbd (patch)
treeccd4cf44b468d46759aaec96961914c200df1876 /worker/maildir/worker.go
parentf021bfd1c7b7885919cb71884727fd8dfdf8eba7 (diff)
downloadaerc-ea10b329ddd18573fdb066a1a3293c839d839fbd.tar.gz
maildir: replace ListFolder method with FolderMap
Replace ListFolder with a new method that returns a map indexed by folder names instead of a list of folder names. A map is simpler to use and more efficient in case we only want to check the presence of a specific folder in the Maildir store. Signed-off-by: Julian Pidancet <julian.pidancet@oracle.com> Acked-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'worker/maildir/worker.go')
-rw-r--r--worker/maildir/worker.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/worker/maildir/worker.go b/worker/maildir/worker.go
index d2bb6464..a9c45ce8 100644
--- a/worker/maildir/worker.go
+++ b/worker/maildir/worker.go
@@ -329,12 +329,12 @@ func (w *Worker) handleListDirectories(msg *types.ListDirectories) error {
if w.c == nil {
return errors.New("Incorrect maildir directory")
}
- dirs, err := w.c.Store.ListFolders()
+ dirs, err := w.c.Store.FolderMap()
if err != nil {
logging.Errorf("failed listing directories: %v", err)
return err
}
- for _, name := range dirs {
+ for name := range dirs {
w.worker.PostMessage(&types.Directory{
Message: types.RespondTo(msg),
Dir: &models.Directory{
@@ -733,12 +733,12 @@ func (w *Worker) handleCheckMail(msg *types.CheckMail) {
if err != nil {
w.err(msg, fmt.Errorf("checkmail: error running command: %w", err))
} else {
- dirs, err := w.c.Store.ListFolders()
+ dirs, err := w.c.Store.FolderMap()
if err != nil {
w.err(msg, fmt.Errorf("failed listing directories: %w", err))
}
- for _, name := range dirs {
- err := w.c.SyncNewMail(w.c.Store.Dir(name))
+ for name, dir := range dirs {
+ err := w.c.SyncNewMail(dir)
if err != nil {
w.err(msg, fmt.Errorf("could not sync new mail: %w", err))
}