about summary refs log tree commit diff stats
path: root/worker/maildir
diff options
context:
space:
mode:
Diffstat (limited to 'worker/maildir')
-rw-r--r--worker/maildir/worker.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/worker/maildir/worker.go b/worker/maildir/worker.go
index d1ff3c2..4a7ae51 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 {