diff options
author | Julian Pidancet <julian.pidancet@oracle.com> | 2022-10-26 22:29:02 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-10-27 21:39:41 +0200 |
commit | f021bfd1c7b7885919cb71884727fd8dfdf8eba7 (patch) | |
tree | 0fe6ce6d038630d0d244b878d2eaf276ee90d0b4 /worker/maildir/worker.go | |
parent | 19d16420de3748cdcae2dc9d1a123a1f6fb2425b (diff) | |
download | aerc-f021bfd1c7b7885919cb71884727fd8dfdf8eba7.tar.gz |
maildir: move common maildir code out of worker
This change moves code that could be common to both notmuch and maildir
workers in worker/lib.
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.go | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/worker/maildir/worker.go b/worker/maildir/worker.go index ddb1bf68..d2bb6464 100644 --- a/worker/maildir/worker.go +++ b/worker/maildir/worker.go @@ -182,7 +182,7 @@ func (w *Worker) getDirectoryInfo(name string) *models.DirectoryInfo { }, } - dir := w.c.Dir(name) + dir := w.c.Store.Dir(name) var keyFlags map[string][]maildir.Flag files, err := dirFiles(string(dir)) if err == nil { @@ -329,7 +329,7 @@ func (w *Worker) handleListDirectories(msg *types.ListDirectories) error { if w.c == nil { return errors.New("Incorrect maildir directory") } - dirs, err := w.c.ListFolders() + dirs, err := w.c.Store.ListFolders() if err != nil { logging.Errorf("failed listing directories: %v", err) return err @@ -453,7 +453,7 @@ func (w *Worker) sort(uids []uint32, criteria []*types.SortCriterion) ([]uint32, } func (w *Worker) handleCreateDirectory(msg *types.CreateDirectory) error { - dir := w.c.Dir(msg.Directory) + dir := w.c.Store.Dir(msg.Directory) if err := dir.Init(); err != nil { logging.Errorf("could not create directory %s: %v", msg.Directory, err) @@ -463,7 +463,7 @@ func (w *Worker) handleCreateDirectory(msg *types.CreateDirectory) error { } func (w *Worker) handleRemoveDirectory(msg *types.RemoveDirectory) error { - dir := w.c.Dir(msg.Directory) + dir := w.c.Store.Dir(msg.Directory) if err := os.RemoveAll(string(dir)); err != nil { logging.Errorf("could not remove directory %s: %v", msg.Directory, err) @@ -604,7 +604,7 @@ func (w *Worker) handleFlagMessages(msg *types.FlagMessages) error { w.err(msg, err) continue } - flag := flagToMaildir[msg.Flag] + flag := lib.FlagToMaildir[msg.Flag] if err := m.SetOneFlag(flag, msg.Enable); err != nil { logging.Errorf("could change flag %v to %v on message: %v", flag, msg.Enable, err) w.err(msg, err) @@ -631,7 +631,7 @@ func (w *Worker) handleFlagMessages(msg *types.FlagMessages) error { } func (w *Worker) handleCopyMessages(msg *types.CopyMessages) error { - dest := w.c.Dir(msg.Destination) + dest := w.c.Store.Dir(msg.Destination) err := w.c.CopyAll(dest, *w.selected, msg.Uids) if err != nil { return err @@ -645,7 +645,7 @@ func (w *Worker) handleCopyMessages(msg *types.CopyMessages) error { } func (w *Worker) handleMoveMessages(msg *types.MoveMessages) error { - dest := w.c.Dir(msg.Destination) + dest := w.c.Store.Dir(msg.Destination) moved, err := w.c.MoveAll(dest, *w.selected, msg.Uids) destInfo := w.getDirectoryInfo(msg.Destination) w.worker.PostMessage(&types.DirectoryInfo{ @@ -660,8 +660,8 @@ func (w *Worker) handleMoveMessages(msg *types.MoveMessages) error { func (w *Worker) handleAppendMessage(msg *types.AppendMessage) error { // since we are the "master" maildir process, we can modify the maildir directly - dest := w.c.Dir(msg.Destination) - _, writer, err := dest.Create(translateFlags(msg.Flags)) + dest := w.c.Store.Dir(msg.Destination) + _, writer, err := dest.Create(lib.ToMaildirFlags(msg.Flags)) if err != nil { logging.Errorf("could not create message at %s: %v", msg.Destination, err) return err @@ -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.ListFolders() + dirs, err := w.c.Store.ListFolders() if err != nil { w.err(msg, fmt.Errorf("failed listing directories: %w", err)) } for _, name := range dirs { - err := w.c.SyncNewMail(w.c.Dir(name)) + err := w.c.SyncNewMail(w.c.Store.Dir(name)) if err != nil { w.err(msg, fmt.Errorf("could not sync new mail: %w", err)) } |