summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2022-11-12 10:02:01 -0800
committerKevin McCarthy <kevin@8t8.us>2023-03-12 19:42:27 -0700
commit9f01d4ab0b8af067897612a46ef5cb8b4f38b699 (patch)
treeca5611044783173fa6d950644b7c18f1bbfecbbc
parent216dd145d41dd079fc9676fd2eb09ad16097627d (diff)
Abort imap_fast_trash() if previously checkpointed.
We don't want to copy the deleted flag over to the trash folder too. I looked into various ways to keep the UID COPY, but they lead to niggling issues with error handling along with handling if the server sends flag updates back to the client. So for that (hopefully rare) case, abort the fast trash and just use a regular copy.
-rw-r--r--imap/imap.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/imap/imap.c b/imap/imap.c
index b92c2dcf..20b10ee4 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -2519,6 +2519,25 @@ int imap_fast_trash (CONTEXT* ctx, char* dest)
return 1;
}
+ /* Scan if any of the messages were previously checkpoint-deleted
+ * on the server, by answering "no" to $delete for instance.
+ * In that case, doing a UID COPY would also copy the deleted flag, which
+ * is probably not desired. Trying to work around that leads to all sorts
+ * of headaches, so just force a manual append.
+ */
+ for (n = 0; n < ctx->msgcount; n++)
+ {
+ if (ctx->hdrs[n]->active &&
+ ctx->hdrs[n]->deleted && !ctx->hdrs[n]->purge &&
+ HEADER_DATA(ctx->hdrs[n])->deleted)
+ {
+ dprint (1, (debugfile,
+ "imap_fast_trash: server-side delete flag set. aborting.\n"));
+ rc = -1;
+ goto out;
+ }
+ }
+
imap_fix_path (idata, mx.mbox, mbox, sizeof (mbox));
if (!*mbox)
strfcpy (mbox, "INBOX", sizeof (mbox));