diff options
Diffstat (limited to 'worker/maildir/worker.go')
-rw-r--r-- | worker/maildir/worker.go | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/worker/maildir/worker.go b/worker/maildir/worker.go index a770b2f4..9f9fee9a 100644 --- a/worker/maildir/worker.go +++ b/worker/maildir/worker.go @@ -46,7 +46,7 @@ type Worker struct { func NewWorker(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 nil, fmt.Errorf("could not create file system watcher: %w", err) } return &Worker{worker: worker, watcher: watch}, nil } @@ -55,7 +55,7 @@ func NewWorker(worker *types.Worker) (types.Backend, error) { 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 nil, fmt.Errorf("could not create file system watcher: %w", err) } return &Worker{worker: worker, watcher: watch, maildirpp: true}, nil } @@ -112,18 +112,18 @@ func (w *Worker) handleFSEvent(ev fsnotify.Event) { } err := w.c.SyncNewMail(*w.selected) if err != nil { - logging.Errorf("could not move new to cur : %v", err) + logging.Errorf("could not move new to cur : %w", err) return } uids, err := w.c.UIDs(*w.selected) if err != nil { - logging.Errorf("could not scan UIDs: %v", err) + logging.Errorf("could not scan UIDs: %w", err) return } sortedUids, err := w.sort(uids, w.currentSortCriteria) if err != nil { - logging.Errorf("error sorting directory: %v", err) + logging.Errorf("error sorting directory: %w", err) return } w.worker.PostMessage(&types.DirectoryContents{ @@ -204,18 +204,18 @@ func (w *Worker) getDirectoryInfo(name string) *models.DirectoryInfo { for _, v := range files { key, flags, err := splitMaildirFile(v) if err != nil { - logging.Errorf("%q: error parsing flags (%q): %v", v, key, err) + logging.Errorf("%q: error parsing flags (%q): %w", v, key, err) continue } keyFlags[key] = flags } } else { - logging.Infof("disabled flags cache: %q: %v", dir, err) + logging.Infof("disabled flags cache: %q: %w", dir, err) } uids, err := w.c.UIDs(dir) if err != nil { - logging.Errorf("could not get uids: %v", err) + logging.Errorf("could not get uids: %w", err) return dirInfo } @@ -223,7 +223,7 @@ func (w *Worker) getDirectoryInfo(name string) *models.DirectoryInfo { for _, uid := range uids { message, err := w.c.Message(dir, uid) if err != nil { - logging.Errorf("could not get message: %v", err) + logging.Errorf("could not get message: %w", err) continue } var flags []maildir.Flag @@ -234,14 +234,14 @@ func (w *Worker) getDirectoryInfo(name string) *models.DirectoryInfo { logging.Debugf("message (key=%q uid=%d) not found in map cache", message.key, message.uid) flags, err = message.Flags() if err != nil { - logging.Errorf("could not get flags: %v", err) + logging.Errorf("could not get flags: %w", err) continue } } } else { flags, err = message.Flags() if err != nil { - logging.Errorf("could not get flags: %v", err) + logging.Errorf("could not get flags: %w", err) continue } } @@ -306,14 +306,14 @@ func (w *Worker) handleMessage(msg types.WorkerMessage) error { func (w *Worker) handleConfigure(msg *types.Configure) error { u, err := url.Parse(msg.Config.Source) if err != nil { - logging.Errorf("error configuring maildir worker: %v", err) + logging.Errorf("error configuring maildir worker: %w", err) return err } dir := u.Path if u.Host == "~" { home, err := os.UserHomeDir() if err != nil { - return fmt.Errorf("could not resolve home directory: %v", err) + return fmt.Errorf("could not resolve home directory: %w", err) } dir = filepath.Join(home, u.Path) } @@ -343,7 +343,7 @@ func (w *Worker) handleListDirectories(msg *types.ListDirectories) error { } dirs, err := w.c.ListFolders() if err != nil { - logging.Errorf("failed listing directories: %v", err) + logging.Errorf("failed listing directories: %w", err) return err } for _, name := range dirs { @@ -375,11 +375,11 @@ func (w *Worker) handleOpenDirectory(msg *types.OpenDirectory) error { if w.selected != nil { prevDir := filepath.Join(string(*w.selected), "new") if err := w.watcher.Remove(prevDir); err != nil { - return fmt.Errorf("could not unwatch previous directory: %v", err) + return fmt.Errorf("could not unwatch previous directory: %w", err) } prevDir = filepath.Join(string(*w.selected), "cur") if err := w.watcher.Remove(prevDir); err != nil { - return fmt.Errorf("could not unwatch previous directory: %v", err) + return fmt.Errorf("could not unwatch previous directory: %w", err) } } @@ -389,15 +389,15 @@ func (w *Worker) handleOpenDirectory(msg *types.OpenDirectory) error { // add watch paths newDir := filepath.Join(string(*w.selected), "new") if err := w.watcher.Add(newDir); err != nil { - return fmt.Errorf("could not add watch to directory: %v", err) + return fmt.Errorf("could not add watch to directory: %w", err) } newDir = filepath.Join(string(*w.selected), "cur") if err := w.watcher.Add(newDir); err != nil { - return fmt.Errorf("could not add watch to directory: %v", err) + return fmt.Errorf("could not add watch to directory: %w", err) } if err := dir.Clean(); err != nil { - return fmt.Errorf("could not clean directory: %v", err) + return fmt.Errorf("could not clean directory: %w", err) } info := &types.DirectoryInfo{ @@ -426,13 +426,13 @@ func (w *Worker) handleFetchDirectoryContents( } else { uids, err = w.c.UIDs(*w.selected) if err != nil { - logging.Errorf("failed scanning uids: %v", err) + logging.Errorf("failed scanning uids: %w", err) return err } } sortedUids, err := w.sort(uids, msg.SortCriteria) if err != nil { - logging.Errorf("failed sorting directory: %v", err) + logging.Errorf("failed sorting directory: %w", err) return err } w.currentSortCriteria = msg.SortCriteria @@ -451,14 +451,14 @@ func (w *Worker) sort(uids []uint32, criteria []*types.SortCriterion) ([]uint32, for _, uid := range uids { info, err := w.msgInfoFromUid(uid) if err != nil { - logging.Errorf("could not get message info: %v", err) + logging.Errorf("could not get message info: %w", err) continue } msgInfos = append(msgInfos, info) } sortedUids, err := lib.Sort(msgInfos, criteria) if err != nil { - logging.Errorf("could not sort the messages: %v", err) + logging.Errorf("could not sort the messages: %w", err) return nil, err } return sortedUids, nil @@ -467,7 +467,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) if err := dir.Init(); err != nil { - logging.Errorf("could not create directory %s: %v", + logging.Errorf("could not create directory %s: %w", msg.Directory, err) return err } @@ -477,7 +477,7 @@ func (w *Worker) handleCreateDirectory(msg *types.CreateDirectory) error { func (w *Worker) handleRemoveDirectory(msg *types.RemoveDirectory) error { dir := w.c.Dir(msg.Directory) if err := os.RemoveAll(string(dir)); err != nil { - logging.Errorf("could not remove directory %s: %v", + logging.Errorf("could not remove directory %s: %w", msg.Directory, err) return err } @@ -490,7 +490,7 @@ func (w *Worker) handleFetchMessageHeaders( for _, uid := range msg.Uids { info, err := w.msgInfoFromUid(uid) if err != nil { - logging.Errorf("could not get message info: %v", err) + logging.Errorf("could not get message info: %w", err) w.err(msg, err) continue } @@ -509,13 +509,13 @@ func (w *Worker) handleFetchMessageBodyPart( // get reader m, err := w.c.Message(*w.selected, msg.Uid) if err != nil { - logging.Errorf("could not get message %d: %v", msg.Uid, err) + logging.Errorf("could not get message %d: %w", msg.Uid, err) return err } r, err := m.NewBodyPartReader(msg.Part) if err != nil { logging.Errorf( - "could not get body part reader for message=%d, parts=%#v: %v", + "could not get body part reader for message=%d, parts=%#v: %w", msg.Uid, msg.Part, err) return err } @@ -534,12 +534,12 @@ func (w *Worker) handleFetchFullMessages(msg *types.FetchFullMessages) error { for _, uid := range msg.Uids { m, err := w.c.Message(*w.selected, uid) if err != nil { - logging.Errorf("could not get message %d: %v", uid, err) + logging.Errorf("could not get message %d: %w", uid, err) return err } r, err := m.NewReader() if err != nil { - logging.Errorf("could not get message reader: %v", err) + logging.Errorf("could not get message reader: %w", err) return err } defer r.Close() @@ -570,7 +570,7 @@ func (w *Worker) handleDeleteMessages(msg *types.DeleteMessages) error { }, nil) } if err != nil { - logging.Errorf("failed removing messages: %v", err) + logging.Errorf("failed removing messages: %w", err) return err } return nil @@ -580,18 +580,18 @@ func (w *Worker) handleAnsweredMessages(msg *types.AnsweredMessages) error { for _, uid := range msg.Uids { m, err := w.c.Message(*w.selected, uid) if err != nil { - logging.Errorf("could not get message: %v", err) + logging.Errorf("could not get message: %w", err) w.err(msg, err) continue } if err := m.MarkReplied(msg.Answered); err != nil { - logging.Errorf("could not mark message as answered: %v", err) + logging.Errorf("could not mark message as answered: %w", err) w.err(msg, err) continue } info, err := m.MessageInfo() if err != nil { - logging.Errorf("could not get message info: %v", err) + logging.Errorf("could not get message info: %w", err) w.err(msg, err) continue } @@ -612,19 +612,19 @@ func (w *Worker) handleFlagMessages(msg *types.FlagMessages) error { for _, uid := range msg.Uids { m, err := w.c.Message(*w.selected, uid) if err != nil { - logging.Errorf("could not get message: %v", err) + logging.Errorf("could not get message: %w", err) w.err(msg, err) continue } flag := 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) + logging.Errorf("could change flag %v to %v on message: %w", flag, msg.Enable, err) w.err(msg, err) continue } info, err := m.MessageInfo() if err != nil { - logging.Errorf("could not get message info: %v", err) + logging.Errorf("could not get message info: %w", err) w.err(msg, err) continue } @@ -661,12 +661,12 @@ func (w *Worker) handleAppendMessage(msg *types.AppendMessage) error { dest := w.c.Dir(msg.Destination) _, writer, err := dest.Create(translateFlags(msg.Flags)) if err != nil { - logging.Errorf("could not create message at %s: %v", msg.Destination, err) + logging.Errorf("could not create message at %s: %w", msg.Destination, err) return err } defer writer.Close() if _, err := io.Copy(writer, msg.Reader); err != nil { - logging.Errorf("could not write message to destination: %v", err) + logging.Errorf("could not write message to destination: %w", err) return err } w.worker.PostMessage(&types.Done{ @@ -729,7 +729,7 @@ func (w *Worker) handleCheckMail(msg *types.CheckMail) { w.err(msg, fmt.Errorf("checkmail: timed out")) case err := <-ch: if err != nil { - w.err(msg, fmt.Errorf("checkmail: error running command: %v", err)) + w.err(msg, fmt.Errorf("checkmail: error running command: %w", err)) } else { w.done(msg) } |