From 44651b43b3a59d35b98936e0bcd4edf797f68b42 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Fri, 29 Jul 2022 13:30:01 -0500 Subject: [PATCH] checkmail: error if check-mail-cmd is not set Send error message to UI if check-mail-cmd is required but not set. Signed-off-by: Tim Culverhouse Acked-by: Robin Jarry --- worker/maildir/worker.go | 4 ++++ worker/notmuch/worker.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/worker/maildir/worker.go b/worker/maildir/worker.go index ec34455..d60315b 100644 --- a/worker/maildir/worker.go +++ b/worker/maildir/worker.go @@ -708,6 +708,10 @@ func (w *Worker) msgInfoFromUid(uid uint32) (*models.MessageInfo, error) { } func (w *Worker) handleCheckMail(msg *types.CheckMail) { + if msg.Command == "" { + w.err(msg, fmt.Errorf("checkmail: no command specified")) + return + } ctx, cancel := context.WithTimeout(context.Background(), msg.Timeout) defer cancel() cmd := exec.CommandContext(ctx, "sh", "-c", msg.Command) diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go index 28029b2..36ef10f 100644 --- a/worker/notmuch/worker.go +++ b/worker/notmuch/worker.go @@ -647,6 +647,10 @@ func (w *worker) sort(uids []uint32, } func (w *worker) handleCheckMail(msg *types.CheckMail) { + if msg.Command == "" { + w.err(msg, fmt.Errorf("checkmail: no command specified")) + return + } ctx, cancel := context.WithTimeout(context.Background(), msg.Timeout) defer cancel() cmd := exec.CommandContext(ctx, "sh", "-c", msg.Command)