M_NOT_SYNCED => M_SYNCED. now that sync records know their messages, it
is simpler to track the positive case.
This commit is contained in:
parent
f4ce961bab
commit
185769640b
|
@ -119,7 +119,7 @@ typedef struct group_conf {
|
||||||
#define M_DEAD (1<<1) /* expunged */
|
#define M_DEAD (1<<1) /* expunged */
|
||||||
#define M_FLAGS (1<<2) /* flags fetched */
|
#define M_FLAGS (1<<2) /* flags fetched */
|
||||||
#define M_PROCESSED (1<<3) /* registered in pair */
|
#define M_PROCESSED (1<<3) /* registered in pair */
|
||||||
#define M_NOT_SYNCED (1<<4) /* not in remote mailbox, yet */
|
#define M_SYNCED (1<<4) /* already propagated */
|
||||||
#define M_EXPIRED (1<<5) /* kicked out by MaxMessages */
|
#define M_EXPIRED (1<<5) /* kicked out by MaxMessages */
|
||||||
|
|
||||||
typedef struct message {
|
typedef struct message {
|
||||||
|
|
25
src/sync.c
25
src/sync.c
|
@ -126,6 +126,8 @@ findmsgs( sync_rec_t *srecs, store_t *ctx[], int t )
|
||||||
continue;
|
continue;
|
||||||
found:
|
found:
|
||||||
msg->status |= M_PROCESSED;
|
msg->status |= M_PROCESSED;
|
||||||
|
if (srec->uid[1-t] >= 0)
|
||||||
|
msg->status |= M_SYNCED;
|
||||||
srec->msg[t] = msg;
|
srec->msg[t] = msg;
|
||||||
nsrec = srec->next;
|
nsrec = srec->next;
|
||||||
debug( "pairs %5d %s\n", srec->uid[1-t], diag );
|
debug( "pairs %5d %s\n", srec->uid[1-t], diag );
|
||||||
|
@ -630,7 +632,6 @@ sync_boxes( store_t *ctx[], const char *names[], channel_conf_t *chan )
|
||||||
if (chan->ops[t] & OP_RENEW) {
|
if (chan->ops[t] & OP_RENEW) {
|
||||||
if ((chan->ops[t] & OP_EXPUNGE) && (srec->msg[1-t]->flags & F_DELETED)) {
|
if ((chan->ops[t] & OP_EXPUNGE) && (srec->msg[1-t]->flags & F_DELETED)) {
|
||||||
debug( " -> not %sing - would be expunged anyway\n", str_hl[t] );
|
debug( " -> not %sing - would be expunged anyway\n", str_hl[t] );
|
||||||
srec->msg[1-t]->status |= M_NOT_SYNCED;
|
|
||||||
} else {
|
} else {
|
||||||
if ((srec->msg[1-t]->flags & F_FLAGGED) || !chan->stores[t]->max_size || srec->msg[1-t]->size <= chan->stores[t]->max_size) {
|
if ((srec->msg[1-t]->flags & F_FLAGGED) || !chan->stores[t]->max_size || srec->msg[1-t]->size <= chan->stores[t]->max_size) {
|
||||||
debug( " -> %sing it\n", str_hl[t] );
|
debug( " -> %sing it\n", str_hl[t] );
|
||||||
|
@ -638,7 +639,7 @@ sync_boxes( store_t *ctx[], const char *names[], channel_conf_t *chan )
|
||||||
switch (driver[1-t]->fetch_msg( ctx[1-t], srec->msg[1-t], &msgdata )) {
|
switch (driver[1-t]->fetch_msg( ctx[1-t], srec->msg[1-t], &msgdata )) {
|
||||||
case DRV_STORE_BAD: ret = SYNC_BAD(1-t); goto finish;
|
case DRV_STORE_BAD: ret = SYNC_BAD(1-t); goto finish;
|
||||||
case DRV_BOX_BAD: ret = SYNC_FAIL; goto finish;
|
case DRV_BOX_BAD: ret = SYNC_FAIL; goto finish;
|
||||||
default: /* ok */ srec->msg[1-t]->status |= M_NOT_SYNCED; break;
|
default: /* ok */ break;
|
||||||
case DRV_OK:
|
case DRV_OK:
|
||||||
srec->msg[1-t]->flags = msgdata.flags;
|
srec->msg[1-t]->flags = msgdata.flags;
|
||||||
switch (driver[t]->store_msg( ctx[t], &msgdata, &uid )) {
|
switch (driver[t]->store_msg( ctx[t], &msgdata, &uid )) {
|
||||||
|
@ -647,16 +648,15 @@ sync_boxes( store_t *ctx[], const char *names[], channel_conf_t *chan )
|
||||||
case DRV_OK:
|
case DRV_OK:
|
||||||
Fprintf( jfp, "%c %d %d %d\n", "<>"[t], srec->uid[M], srec->uid[S], uid );
|
Fprintf( jfp, "%c %d %d %d\n", "<>"[t], srec->uid[M], srec->uid[S], uid );
|
||||||
srec->uid[t] = uid;
|
srec->uid[t] = uid;
|
||||||
|
srec->msg[1-t]->status |= M_SYNCED;
|
||||||
nflags = srec->msg[1-t]->flags;
|
nflags = srec->msg[1-t]->flags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug( " -> not %sing - still too big\n", str_hl[t] );
|
debug( " -> not %sing - still too big\n", str_hl[t] );
|
||||||
srec->msg[1-t]->status |= M_NOT_SYNCED;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
srec->msg[1-t]->status |= M_NOT_SYNCED;
|
|
||||||
} else if (!del[t]) {
|
} else if (!del[t]) {
|
||||||
/* a) & b.3) / c.3) */
|
/* a) & b.3) / c.3) */
|
||||||
debug( " may %s\n", str_hl[t] );
|
debug( " may %s\n", str_hl[t] );
|
||||||
|
@ -725,7 +725,6 @@ sync_boxes( store_t *ctx[], const char *names[], channel_conf_t *chan )
|
||||||
debug( "new message %d on %s\n", tmsg->uid, str_ms[1-t] );
|
debug( "new message %d on %s\n", tmsg->uid, str_ms[1-t] );
|
||||||
if ((chan->ops[t] & OP_EXPUNGE) && (tmsg->flags & F_DELETED)) {
|
if ((chan->ops[t] & OP_EXPUNGE) && (tmsg->flags & F_DELETED)) {
|
||||||
debug( " not %sing - would be expunged anyway\n", str_hl[t] );
|
debug( " not %sing - would be expunged anyway\n", str_hl[t] );
|
||||||
tmsg->status |= M_NOT_SYNCED;
|
|
||||||
} else {
|
} else {
|
||||||
if ((tmsg->flags & F_FLAGGED) || !chan->stores[t]->max_size || tmsg->size <= chan->stores[t]->max_size) {
|
if ((tmsg->flags & F_FLAGGED) || !chan->stores[t]->max_size || tmsg->size <= chan->stores[t]->max_size) {
|
||||||
debug( " %sing it\n", str_hl[t] );
|
debug( " %sing it\n", str_hl[t] );
|
||||||
|
@ -738,17 +737,16 @@ sync_boxes( store_t *ctx[], const char *names[], channel_conf_t *chan )
|
||||||
switch (driver[1-t]->fetch_msg( ctx[1-t], tmsg, &msgdata )) {
|
switch (driver[1-t]->fetch_msg( ctx[1-t], tmsg, &msgdata )) {
|
||||||
case DRV_STORE_BAD: return SYNC_BAD(1-t);
|
case DRV_STORE_BAD: return SYNC_BAD(1-t);
|
||||||
case DRV_BOX_BAD: return SYNC_FAIL;
|
case DRV_BOX_BAD: return SYNC_FAIL;
|
||||||
case DRV_MSG_BAD: /* ok */ tmsg->status |= M_NOT_SYNCED; continue;
|
case DRV_MSG_BAD: /* ok */ continue;
|
||||||
}
|
}
|
||||||
tmsg->flags = msgdata.flags;
|
tmsg->flags = msgdata.flags;
|
||||||
switch (driver[t]->store_msg( ctx[t], &msgdata, &uid )) {
|
switch (driver[t]->store_msg( ctx[t], &msgdata, &uid )) {
|
||||||
case DRV_STORE_BAD: return SYNC_BAD(t);
|
case DRV_STORE_BAD: return SYNC_BAD(t);
|
||||||
default: return SYNC_FAIL;
|
default: return SYNC_FAIL;
|
||||||
case DRV_OK: break;
|
case DRV_OK: tmsg->status |= M_SYNCED; break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug( " not %sing - too big\n", str_hl[t] );
|
debug( " not %sing - too big\n", str_hl[t] );
|
||||||
tmsg->status |= M_NOT_SYNCED;
|
|
||||||
uid = -1;
|
uid = -1;
|
||||||
}
|
}
|
||||||
srec = nfmalloc( sizeof(*srec) );
|
srec = nfmalloc( sizeof(*srec) );
|
||||||
|
@ -765,8 +763,7 @@ sync_boxes( store_t *ctx[], const char *names[], channel_conf_t *chan )
|
||||||
Fprintf( jfp, "%c %d\n", ")("[t], tmsg->uid );
|
Fprintf( jfp, "%c %d\n", ")("[t], tmsg->uid );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
tmsg->status |= M_NOT_SYNCED;
|
|
||||||
}
|
}
|
||||||
if (nmsgs)
|
if (nmsgs)
|
||||||
info( " %d messages\n", nmsgs );
|
info( " %d messages\n", nmsgs );
|
||||||
|
@ -782,7 +779,7 @@ sync_boxes( store_t *ctx[], const char *names[], channel_conf_t *chan )
|
||||||
for (tmsg = ctx[S]->msgs; tmsg && todel > 0; tmsg = tmsg->next) {
|
for (tmsg = ctx[S]->msgs; tmsg && todel > 0; tmsg = tmsg->next) {
|
||||||
if ((tmsg->status & M_DEAD) || (tmsg->flags & F_DELETED))
|
if ((tmsg->status & M_DEAD) || (tmsg->flags & F_DELETED))
|
||||||
continue;
|
continue;
|
||||||
if ((tmsg->flags & F_FLAGGED) || (tmsg->status & M_NOT_SYNCED)) /* add M_DESYNCED? */
|
if ((tmsg->flags & F_FLAGGED) || !(tmsg->status & M_SYNCED)) /* add M_DESYNCED? */
|
||||||
todel--;
|
todel--;
|
||||||
else if (!(tmsg->status & M_RECENT)) {
|
else if (!(tmsg->status & M_RECENT)) {
|
||||||
tmsg->status |= M_EXPIRED;
|
tmsg->status |= M_EXPIRED;
|
||||||
|
@ -824,7 +821,7 @@ sync_boxes( store_t *ctx[], const char *names[], channel_conf_t *chan )
|
||||||
for (tmsg = ctx[t]->msgs; tmsg; tmsg = tmsg->next)
|
for (tmsg = ctx[t]->msgs; tmsg; tmsg = tmsg->next)
|
||||||
if (tmsg->flags & F_DELETED) {
|
if (tmsg->flags & F_DELETED) {
|
||||||
if (ctx[t]->conf->trash) {
|
if (ctx[t]->conf->trash) {
|
||||||
if (!ctx[t]->conf->trash_only_new || (tmsg->status & M_NOT_SYNCED)) {
|
if (!ctx[t]->conf->trash_only_new || !(tmsg->status & M_SYNCED)) {
|
||||||
debug( " trashing message %d\n", tmsg->uid );
|
debug( " trashing message %d\n", tmsg->uid );
|
||||||
switch (driver[t]->trash_msg( ctx[t], tmsg )) {
|
switch (driver[t]->trash_msg( ctx[t], tmsg )) {
|
||||||
case DRV_OK: break;
|
case DRV_OK: break;
|
||||||
|
@ -834,7 +831,7 @@ sync_boxes( store_t *ctx[], const char *names[], channel_conf_t *chan )
|
||||||
} else
|
} else
|
||||||
debug( " not trashing message %d - not new\n", tmsg->uid );
|
debug( " not trashing message %d - not new\n", tmsg->uid );
|
||||||
} else if (ctx[1-t]->conf->trash && ctx[1-t]->conf->trash_remote_new) {
|
} else if (ctx[1-t]->conf->trash && ctx[1-t]->conf->trash_remote_new) {
|
||||||
if (tmsg->status & M_NOT_SYNCED) {
|
if (!(tmsg->status & M_SYNCED)) {
|
||||||
if (!ctx[1-t]->conf->max_size || tmsg->size <= ctx[1-t]->conf->max_size) {
|
if (!ctx[1-t]->conf->max_size || tmsg->size <= ctx[1-t]->conf->max_size) {
|
||||||
debug( " remote trashing message %d\n", tmsg->uid );
|
debug( " remote trashing message %d\n", tmsg->uid );
|
||||||
msgdata.flags = tmsg->flags;
|
msgdata.flags = tmsg->flags;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user