commit 13764a94b96c153411ebf74bb79c10bfa48191af
Author: Oswald Buddenhagen <o...@users.sf.net>
Date:   Sun Feb 6 14:56:16 2022 +0100

    don't expunge until all flag propagation is complete
    
    so far, we ensured that propagation _into_ a store completes before
    expunging it, but not that propagation _from_ it completes. this way we
    could end up expunging the source messages before the changes reached
    the target, which could mess up resuming after an interruption.

 src/sync.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/sync.c b/src/sync.c
index ba7e12ba..2e842831 100644
--- a/src/sync.c
+++ b/src/sync.c
@@ -40,7 +40,7 @@ static int check_cancel( sync_vars_t *svars );
    new(F), new(N), flags(F), flags(N): load(F) & load(N)
    find_new(x): new(x)
    trash(x): flags(x)
-   close(x): trash(x) & find_new(x) & new(!x) // with expunge
+   close(x): trash(x) & flags(!x) & find_new(x) & new(!x) // with expunge
    cleanup: close(F) & close(N)
 */
 
@@ -1557,6 +1557,10 @@ msgs_flags_set( sync_vars_t *svars, int t )
 
        sync_ref( svars );
 
+       sync_close( svars, t^1 );
+       if (check_cancel( svars ))
+               goto out;
+
        if (!(svars->chan->ops[t] & OP_EXPUNGE))
                goto skip;
        int remote, only_new;
@@ -1683,7 +1687,7 @@ static void
 sync_close( sync_vars_t *svars, int t )
 {
        if ((~svars->state[t] & (ST_FOUND_NEW|ST_SENT_TRASH)) || 
svars->trash_pending[t] ||
-           !(svars->state[t^1] & ST_SENT_NEW) || svars->new_pending[t^1])
+           (~svars->state[t^1] & (ST_SENT_NEW | ST_SENT_FLAGS)) || 
svars->new_pending[t^1] || svars->flags_pending[t^1])
                return;
 
        if (svars->state[t] & ST_CLOSING)


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

Reply via email to