commit edbf9a35daf954ad1a032e1030269f8119b0fa78
Author: Oswald Buddenhagen <o...@users.sf.net>
Date:   Wed Dec 29 14:20:04 2021 +0100

    use UID EXPUNGE also when trashing remotely
    
    amends 2f0fbcd3.

 src/driver.h      | 3 +++
 src/drv_imap.c    | 4 +++-
 src/drv_maildir.c | 2 +-
 src/sync.c        | 4 ++--
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/driver.h b/src/driver.h
index bcb036b3..aea4fae8 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -97,6 +97,9 @@ BIT_ENUM(
        OPEN_APPEND,
        OPEN_SETFLAGS,
        OPEN_EXPUNGE,
+       // Expunge only deleted messages we know about. Relies on 
OPEN_{OLD,NEW,FLAGS}
+       // being set externally. The driver may unset it if it can't handle it.
+       OPEN_UID_EXPUNGE,
 )
 
 #define UIDVAL_BAD ((uint)-1)
diff --git a/src/drv_imap.c b/src/drv_imap.c
index e70654df..f07ab730 100644
--- a/src/drv_imap.c
+++ b/src/drv_imap.c
@@ -2812,6 +2812,8 @@ imap_prepare_load_box( store_t *gctx, uint opts )
 {
        imap_store_t *ctx = (imap_store_t *)gctx;
 
+       if (!CAP(UIDPLUS))
+               opts &= ~OPEN_UID_EXPUNGE;
        ctx->opts = opts;
        return opts;
 }
@@ -3129,7 +3131,7 @@ imap_close_box( store_t *gctx,
 
        assert( !ctx->num_wait_check );
 
-       if (ctx->conf->trash && CAP(UIDPLUS)) {
+       if (ctx->opts & OPEN_UID_EXPUNGE) {
                INIT_REFCOUNTED_STATE(imap_expunge_state_t, sts, cb, aux)
                imap_message_t *msg, *fmsg, *nmsg;
                int bl;
diff --git a/src/drv_maildir.c b/src/drv_maildir.c
index de0e4f23..3bc730cc 100644
--- a/src/drv_maildir.c
+++ b/src/drv_maildir.c
@@ -1406,7 +1406,7 @@ maildir_prepare_load_box( store_t *gctx, uint opts )
        if (opts & OPEN_SETFLAGS)
                opts |= OPEN_PAIRED;
        if (opts & OPEN_EXPUNGE)
-               opts |= OPEN_PAIRED | OPEN_OLD | OPEN_NEW | OPEN_FLAGS;
+               opts |= OPEN_PAIRED | OPEN_OLD | OPEN_NEW | OPEN_FLAGS | 
OPEN_UID_EXPUNGE;
        ctx->opts = opts;
        return opts;
 }
diff --git a/src/sync.c b/src/sync.c
index a671fbe2..31d52652 100644
--- a/src/sync.c
+++ b/src/sync.c
@@ -793,9 +793,9 @@ box_opened2( sync_vars_t *svars, int t )
                        if (chan->stores[t]->trash) {
                                if (!chan->stores[t]->trash_only_new)
                                        opts[t] |= OPEN_OLD;
-                               opts[t] |= OPEN_NEW|OPEN_FLAGS;
+                               opts[t] |= OPEN_NEW | OPEN_FLAGS | 
OPEN_UID_EXPUNGE;
                        } else if (chan->stores[t^1]->trash && 
chan->stores[t^1]->trash_remote_new) {
-                               opts[t] |= OPEN_NEW|OPEN_FLAGS;
+                               opts[t] |= OPEN_NEW | OPEN_FLAGS | 
OPEN_UID_EXPUNGE;
                        }
                }
        }


_______________________________________________
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to