mbox: implement MoveMessages handling

Implement MoveMessages handling in the mbox backend. The mbox backend
exists entirely in memory, so the handling is equivalent to a
copy-and-delete.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Tim Culverhouse 2022-08-16 16:23:38 -05:00 committed by Robin Jarry
parent e8c5bb641a
commit 57933f65ab

View file

@ -295,6 +295,24 @@ func (w *mboxWorker) handleMessage(msg types.WorkerMessage) error {
w.worker.PostMessage( w.worker.PostMessage(
&types.Done{Message: types.RespondTo(msg)}, nil) &types.Done{Message: types.RespondTo(msg)}, nil)
case *types.MoveMessages:
err := w.data.Copy(msg.Destination, w.name, msg.Uids)
if err != nil {
reterr = err
break
}
deleted := w.folder.Delete(msg.Uids)
if len(deleted) > 0 {
w.worker.PostMessage(&types.MessagesDeleted{
Message: types.RespondTo(msg),
Uids: deleted,
}, nil)
}
w.worker.PostMessage(&types.DirectoryInfo{
Info: w.data.DirectoryInfo(msg.Destination),
}, nil)
w.worker.PostMessage(
&types.Done{Message: types.RespondTo(msg)}, nil)
case *types.SearchDirectory: case *types.SearchDirectory:
uids, err := filterUids(w.folder, w.folder.Uids(), msg.Argv) uids, err := filterUids(w.folder, w.folder.Uids(), msg.Argv)