Browse Source

split OPEN_PAIRED from OPEN_OLD, and rename OPEN_OLD_IDS accordingly

this emphasizes the non-complementarity to OPEN_NEW.
the "real" OPEN_OLD is currently used only for trashing.
wip/maildir-path-under-inbox
Oswald Buddenhagen 3 years ago
parent
commit
a8e145e589
  1. 9
      src/driver.h
  2. 4
      src/drv_imap.c
  3. 6
      src/drv_maildir.c
  4. 42
      src/sync.c

9
src/driver.h

@ -82,16 +82,17 @@ static_assert_bits(F, message_t, flags);
static_assert_bits(M, message_t, status); static_assert_bits(M, message_t, status);
// For driver_t->prepare_load_box(), which may amend the passed flags. // For driver_t->prepare_load_box(), which may amend the passed flags.
// The drivers don't use the first two, but may set them if loading the // The drivers don't use the first three, but may set them if loading the
// particular range is required to handle some other flag; note that these // particular range is required to handle some other flag; note that these
// ranges may overlap. // ranges may overlap.
BIT_ENUM( BIT_ENUM(
OPEN_OLD, // Paired messages *in* this store. OPEN_PAIRED, // Paired messages *in* this store.
OPEN_OLD, // Messages that should be already propagated *from* this store.
OPEN_NEW, // Messages (possibly) not yet propagated *from* this store. OPEN_NEW, // Messages (possibly) not yet propagated *from* this store.
OPEN_FIND, OPEN_FIND,
OPEN_FLAGS, // Note that fetch_msg() gets the flags regardless. OPEN_FLAGS, // Note that fetch_msg() gets the flags regardless.
OPEN_NEW_SIZE, OPEN_NEW_SIZE,
OPEN_OLD_IDS, OPEN_PAIRED_IDS,
OPEN_APPEND, OPEN_APPEND,
OPEN_SETFLAGS, OPEN_SETFLAGS,
OPEN_EXPUNGE, OPEN_EXPUNGE,
@ -235,7 +236,7 @@ struct driver {
* and those named in the excs array (smaller than minuid). * and those named in the excs array (smaller than minuid).
* The driver takes ownership of the excs array. * The driver takes ownership of the excs array.
* Messages starting with finduid need to have the TUID populated when OPEN_FIND is set. * Messages starting with finduid need to have the TUID populated when OPEN_FIND is set.
* Messages up to pairuid need to have the Message-Id populated when OPEN_OLD_IDS is set. * Messages up to pairuid need to have the Message-Id populated when OPEN_PAIRED_IDS is set.
* Messages up to newuid need to have the size populated when OPEN_OLD_SIZE is set; * Messages up to newuid need to have the size populated when OPEN_OLD_SIZE is set;
* likewise messages above newuid when OPEN_NEW_SIZE is set. * likewise messages above newuid when OPEN_NEW_SIZE is set.
* The returned message list remains owned by the driver. */ * The returned message list remains owned by the driver. */

4
src/drv_imap.c

@ -2885,7 +2885,7 @@ imap_load_box( store_t *gctx, uint minuid, uint maxuid, uint finduid, uint pairu
if (i != j) if (i != j)
bl += sprintf( buf + bl, ":%u", excs.data[i] ); bl += sprintf( buf + bl, ":%u", excs.data[i] );
} }
imap_submit_load( ctx, buf, shifted_bit( ctx->opts, OPEN_OLD_IDS, WantMsgids ), sts ); imap_submit_load( ctx, buf, shifted_bit( ctx->opts, OPEN_PAIRED_IDS, WantMsgids ), sts );
} }
if (maxuid == UINT_MAX) if (maxuid == UINT_MAX)
maxuid = ctx->uidnext - 1; maxuid = ctx->uidnext - 1;
@ -2899,7 +2899,7 @@ imap_load_box( store_t *gctx, uint minuid, uint maxuid, uint finduid, uint pairu
imap_set_range( ranges, &nranges, 0, WantSize, newuid ); imap_set_range( ranges, &nranges, 0, WantSize, newuid );
if (ctx->opts & OPEN_FIND) if (ctx->opts & OPEN_FIND)
imap_set_range( ranges, &nranges, 0, WantTuids, finduid - 1 ); imap_set_range( ranges, &nranges, 0, WantTuids, finduid - 1 );
if (ctx->opts & OPEN_OLD_IDS) if (ctx->opts & OPEN_PAIRED_IDS)
imap_set_range( ranges, &nranges, WantMsgids, 0, pairuid ); imap_set_range( ranges, &nranges, WantMsgids, 0, pairuid );
for (uint r = 0; r < nranges; r++) { for (uint r = 0; r < nranges; r++) {
sprintf( buf, "%u:%u", ranges[r].first, ranges[r].last ); sprintf( buf, "%u:%u", ranges[r].first, ranges[r].last );

6
src/drv_maildir.c

@ -1113,7 +1113,7 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist )
} }
int want_size = ((ctx->opts & OPEN_NEW_SIZE) && uid > ctx->newuid); int want_size = ((ctx->opts & OPEN_NEW_SIZE) && uid > ctx->newuid);
int want_tuid = ((ctx->opts & OPEN_FIND) && uid >= ctx->finduid); int want_tuid = ((ctx->opts & OPEN_FIND) && uid >= ctx->finduid);
int want_msgid = ((ctx->opts & OPEN_OLD_IDS) && uid <= ctx->pairuid); int want_msgid = ((ctx->opts & OPEN_PAIRED_IDS) && uid <= ctx->pairuid);
if (!want_size && !want_tuid && !want_msgid) if (!want_size && !want_tuid && !want_msgid)
continue; continue;
if (!fnl) if (!fnl)
@ -1401,9 +1401,9 @@ maildir_prepare_load_box( store_t *gctx, uint opts )
maildir_store_t *ctx = (maildir_store_t *)gctx; maildir_store_t *ctx = (maildir_store_t *)gctx;
if (opts & OPEN_SETFLAGS) if (opts & OPEN_SETFLAGS)
opts |= OPEN_OLD; opts |= OPEN_PAIRED;
if (opts & OPEN_EXPUNGE) if (opts & OPEN_EXPUNGE)
opts |= OPEN_OLD|OPEN_NEW|OPEN_FLAGS; opts |= OPEN_PAIRED | OPEN_OLD | OPEN_NEW | OPEN_FLAGS;
ctx->opts = opts; ctx->opts = opts;
return opts; return opts;
} }

42
src/sync.c

@ -741,7 +741,7 @@ box_opened2( sync_vars_t *svars, int t )
opts[F] = opts[N] = 0; opts[F] = opts[N] = 0;
if (fails) if (fails)
opts[F] = opts[N] = OPEN_OLD|OPEN_OLD_IDS; opts[F] = opts[N] = OPEN_PAIRED | OPEN_PAIRED_IDS;
for (t = 0; t < 2; t++) { for (t = 0; t < 2; t++) {
if (any_purges[t]) { if (any_purges[t]) {
debug( "resuming %d %s purge(s)\n", any_purges[t], str_fn[t] ); debug( "resuming %d %s purge(s)\n", any_purges[t], str_fn[t] );
@ -754,7 +754,7 @@ box_opened2( sync_vars_t *svars, int t )
} }
if (chan->ops[t] & (OP_GONE | OP_FLAGS)) { if (chan->ops[t] & (OP_GONE | OP_FLAGS)) {
opts[t] |= OPEN_SETFLAGS; opts[t] |= OPEN_SETFLAGS;
opts[t^1] |= OPEN_OLD; opts[t^1] |= OPEN_PAIRED;
if (chan->ops[t] & OP_FLAGS) if (chan->ops[t] & OP_FLAGS)
opts[t^1] |= OPEN_FLAGS; opts[t^1] |= OPEN_FLAGS;
} }
@ -773,8 +773,8 @@ box_opened2( sync_vars_t *svars, int t )
if ((chan->ops[t] & OP_UPGRADE) || any_upgrades[t]) { if ((chan->ops[t] & OP_UPGRADE) || any_upgrades[t]) {
debug( "resuming %s of %d upgrade(s)\n", str_hl[t], any_upgrades[t] ); debug( "resuming %s of %d upgrade(s)\n", str_hl[t], any_upgrades[t] );
if (chan->ops[t] & OP_UPGRADE) if (chan->ops[t] & OP_UPGRADE)
opts[t] |= OPEN_OLD | OPEN_FLAGS | OPEN_SETFLAGS; opts[t] |= OPEN_PAIRED | OPEN_FLAGS | OPEN_SETFLAGS;
opts[t^1] |= OPEN_OLD; opts[t^1] |= OPEN_PAIRED;
} }
if ((chan->ops[t] | chan->ops[t^1]) & OP_EXPUNGE) // Don't propagate doomed msgs if ((chan->ops[t] | chan->ops[t^1]) & OP_EXPUNGE) // Don't propagate doomed msgs
opts[t^1] |= OPEN_FLAGS; opts[t^1] |= OPEN_FLAGS;
@ -798,9 +798,9 @@ box_opened2( sync_vars_t *svars, int t )
if ((chan->ops[N] & (OP_NEW | OP_UPGRADE | OP_FLAGS)) && chan->max_messages) if ((chan->ops[N] & (OP_NEW | OP_UPGRADE | OP_FLAGS)) && chan->max_messages)
svars->any_expiring = 1; svars->any_expiring = 1;
if (svars->any_expiring) { if (svars->any_expiring) {
opts[N] |= OPEN_OLD | OPEN_FLAGS; opts[N] |= OPEN_PAIRED | OPEN_FLAGS;
if (any_dummies[N]) if (any_dummies[N])
opts[F] |= OPEN_OLD | OPEN_FLAGS; opts[F] |= OPEN_PAIRED | OPEN_FLAGS;
else if (chan->ops[N] & (OP_NEW | OP_UPGRADE)) else if (chan->ops[N] & (OP_NEW | OP_UPGRADE))
opts[F] |= OPEN_FLAGS; opts[F] |= OPEN_FLAGS;
} }
@ -808,7 +808,7 @@ box_opened2( sync_vars_t *svars, int t )
svars->opts[N] = svars->drv[N]->prepare_load_box( ctx[N], opts[N] ); svars->opts[N] = svars->drv[N]->prepare_load_box( ctx[N], opts[N] );
ARRAY_INIT( &mexcs ); ARRAY_INIT( &mexcs );
if ((svars->opts[F] & OPEN_OLD) && chan->max_messages) { if ((svars->opts[F] & OPEN_PAIRED) && !(svars->opts[F] & OPEN_OLD) && chan->max_messages) {
/* When messages have been expired on the near side, the far side fetch is split into /* When messages have been expired on the near side, the far side fetch is split into
* two ranges: The bulk fetch which corresponds with the most recent messages, and an * two ranges: The bulk fetch which corresponds with the most recent messages, and an
* exception list of messages which would have been expired if they weren't important. */ * exception list of messages which would have been expired if they weren't important. */
@ -859,13 +859,29 @@ load_box( sync_vars_t *svars, int t, uint minwuid, uint_array_t mexcs )
uint maxwuid = 0, pairuid = UINT_MAX; uint maxwuid = 0, pairuid = UINT_MAX;
if (svars->opts[t] & OPEN_NEW) { if (svars->opts[t] & OPEN_NEW) {
if (!(svars->opts[t] & OPEN_OLD) || (minwuid > svars->maxuid[t] + 1)) if (svars->opts[t] & OPEN_OLD) {
svars->opts[t] |= OPEN_PAIRED;
minwuid = 1;
} else if (!(svars->opts[t] & OPEN_PAIRED) || (minwuid > svars->maxuid[t] + 1)) {
minwuid = svars->maxuid[t] + 1; minwuid = svars->maxuid[t] + 1;
}
maxwuid = UINT_MAX; maxwuid = UINT_MAX;
if (svars->opts[t] & OPEN_OLD_IDS) // Implies OPEN_OLD if (svars->opts[t] & OPEN_PAIRED_IDS) // Implies OPEN_PAIRED
pairuid = get_seenuid( svars, t ); pairuid = get_seenuid( svars, t );
} else if (svars->opts[t] & OPEN_OLD) { } else if (svars->opts[t] & (OPEN_PAIRED | OPEN_OLD)) {
maxwuid = get_seenuid( svars, t ); uint seenuid = get_seenuid( svars, t );
if (svars->opts[t] & OPEN_OLD) {
minwuid = 1;
maxwuid = svars->maxuid[t];
if (maxwuid < seenuid) {
if (svars->opts[t] & OPEN_PAIRED)
maxwuid = seenuid;
} else {
svars->opts[t] |= OPEN_PAIRED;
}
} else { // OPEN_PAIRED
maxwuid = seenuid;
}
} else { } else {
minwuid = UINT_MAX; minwuid = UINT_MAX;
} }
@ -1030,8 +1046,8 @@ box_loaded( int sts, message_t *msgs, int total_msgs, int recent_msgs, void *aux
debug( "pair (%u,%u)\n", srec->uid[F], srec->uid[N] ); debug( "pair (%u,%u)\n", srec->uid[F], srec->uid[N] );
assert( !srec->tuid[0] ); assert( !srec->tuid[0] );
// no[] means that a message is known to be not there. // no[] means that a message is known to be not there.
no[F] = !srec->msg[F] && (svars->opts[F] & OPEN_OLD); no[F] = !srec->msg[F] && (svars->opts[F] & OPEN_PAIRED);
no[N] = !srec->msg[N] && (svars->opts[N] & OPEN_OLD); no[N] = !srec->msg[N] && (svars->opts[N] & OPEN_PAIRED);
if (no[F] && no[N]) { if (no[F] && no[N]) {
// It does not matter whether one side was already known to be missing // It does not matter whether one side was already known to be missing
// (never stored [skipped or failed] or expunged [possibly expired]) - // (never stored [skipped or failed] or expunged [possibly expired]) -

Loading…
Cancel
Save