aboutsummaryrefslogtreecommitdiffstats
path: root/worker
diff options
context:
space:
mode:
Diffstat (limited to 'worker')
-rw-r--r--worker/imap/remove.go19
-rw-r--r--worker/imap/worker.go2
-rw-r--r--worker/maildir/worker.go12
-rw-r--r--worker/notmuch/worker.go2
-rw-r--r--worker/types/messages.go6
5 files changed, 41 insertions, 0 deletions
diff --git a/worker/imap/remove.go b/worker/imap/remove.go
new file mode 100644
index 00000000..47b1f437
--- /dev/null
+++ b/worker/imap/remove.go
@@ -0,0 +1,19 @@
+package imap
+
+import (
+ "git.sr.ht/~sircmpwn/aerc/worker/types"
+)
+
+func (imapw *IMAPWorker) handleRemoveDirectory(msg *types.RemoveDirectory) {
+ if err := imapw.client.Delete(msg.Directory); err != nil {
+ if msg.Quiet {
+ return
+ }
+ imapw.worker.PostMessage(&types.Error{
+ Message: types.RespondTo(msg),
+ Error: err,
+ }, nil)
+ } else {
+ imapw.worker.PostMessage(&types.Done{types.RespondTo(msg)}, nil)
+ }
+}
diff --git a/worker/imap/worker.go b/worker/imap/worker.go
index 0be51d71..c016af66 100644
--- a/worker/imap/worker.go
+++ b/worker/imap/worker.go
@@ -165,6 +165,8 @@ func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error {
w.handleFetchDirectoryContents(msg)
case *types.CreateDirectory:
w.handleCreateDirectory(msg)
+ case *types.RemoveDirectory:
+ w.handleRemoveDirectory(msg)
case *types.FetchMessageHeaders:
w.handleFetchMessageHeaders(msg)
case *types.FetchMessageBodyPart:
diff --git a/worker/maildir/worker.go b/worker/maildir/worker.go
index d1ff3c2f..4a7ae51f 100644
--- a/worker/maildir/worker.go
+++ b/worker/maildir/worker.go
@@ -186,6 +186,8 @@ func (w *Worker) handleMessage(msg types.WorkerMessage) error {
return w.handleFetchDirectoryContents(msg)
case *types.CreateDirectory:
return w.handleCreateDirectory(msg)
+ case *types.RemoveDirectory:
+ return w.handleRemoveDirectory(msg)
case *types.FetchMessageHeaders:
return w.handleFetchMessageHeaders(msg)
case *types.FetchMessageBodyPart:
@@ -362,6 +364,16 @@ func (w *Worker) handleCreateDirectory(msg *types.CreateDirectory) error {
return nil
}
+func (w *Worker) handleRemoveDirectory(msg *types.RemoveDirectory) error {
+ dir := w.c.Dir(msg.Directory)
+ if err := os.RemoveAll(string(dir)); err != nil {
+ w.worker.Logger.Printf("could not remove directory %s: %v",
+ msg.Directory, err)
+ return err
+ }
+ return nil
+}
+
func (w *Worker) handleFetchMessageHeaders(
msg *types.FetchMessageHeaders) error {
for _, uid := range msg.Uids {
diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go
index f14b7ff0..66d1cd26 100644
--- a/worker/notmuch/worker.go
+++ b/worker/notmuch/worker.go
@@ -131,6 +131,8 @@ func (w *worker) handleMessage(msg types.WorkerMessage) error {
// return w.handleAppendMessage(msg)
// case *types.CreateDirectory:
// return w.handleCreateDirectory(msg)
+ // case *types.RemoveDirectory:
+ // return w.handleRemoveDirectory(msg)
}
return errUnsupported
}
diff --git a/worker/types/messages.go b/worker/types/messages.go
index 374db81f..ab0e5456 100644
--- a/worker/types/messages.go
+++ b/worker/types/messages.go
@@ -92,6 +92,12 @@ type CreateDirectory struct {
Quiet bool
}
+type RemoveDirectory struct {
+ Message
+ Directory string
+ Quiet bool
+}
+
type FetchMessageHeaders struct {
Message
Uids []uint32