diff options
author | Adnan Maolood <me@adnano.co> | 2022-07-04 15:21:48 -0400 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-07-10 20:34:47 +0200 |
commit | c5daf434604f6b282d95ec6e5220c64988b476d9 (patch) | |
tree | 96c94e300dd0a43cf803c4581a94790b1ecc69f4 /worker/maildir/worker.go | |
parent | 4d3156ddf1599b0d647c488f92b1a9ea4d74de7e (diff) | |
download | aerc-c5daf434604f6b282d95ec6e5220c64988b476d9.tar.gz |
worker/maildir: implement Maildir++ support
See https://www.courier-mta.org/maildir.html#maildircontents
Signed-off-by: Adnan Maolood <me@adnano.co>
Acked-by: Koni Marti <koni.marti@gmail.com>
Diffstat (limited to 'worker/maildir/worker.go')
-rw-r--r-- | worker/maildir/worker.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/worker/maildir/worker.go b/worker/maildir/worker.go index 2b55ca6f..cf2970eb 100644 --- a/worker/maildir/worker.go +++ b/worker/maildir/worker.go @@ -25,6 +25,7 @@ import ( func init() { handlers.RegisterWorkerFactory("maildir", NewWorker) + handlers.RegisterWorkerFactory("maildirpp", NewMaildirppWorker) } var errUnsupported = fmt.Errorf("unsupported command") @@ -37,6 +38,7 @@ type Worker struct { worker *types.Worker watcher *fsnotify.Watcher currentSortCriteria []*types.SortCriterion + maildirpp bool // whether to use Maildir++ directory layout } // NewWorker creates a new maildir worker with the provided worker. @@ -48,6 +50,15 @@ func NewWorker(worker *types.Worker) (types.Backend, error) { return &Worker{worker: worker, watcher: watch}, nil } +// NewMaildirppWorker creates a new Maildir++ worker with the provided worker. +func NewMaildirppWorker(worker *types.Worker) (types.Backend, error) { + watch, err := fsnotify.NewWatcher() + if err != nil { + return nil, fmt.Errorf("could not create file system watcher: %v", err) + } + return &Worker{worker: worker, watcher: watch, maildirpp: true}, nil +} + // Run starts the worker's message handling loop. func (w *Worker) Run() { for { @@ -301,7 +312,7 @@ func (w *Worker) handleConfigure(msg *types.Configure) error { if len(dir) == 0 { return fmt.Errorf("could not resolve maildir from URL '%s'", msg.Config.Source) } - c, err := NewContainer(dir, w.worker.Logger) + c, err := NewContainer(dir, w.worker.Logger, w.maildirpp) if err != nil { w.worker.Logger.Printf("could not configure maildir: %s", dir) return err |