CVS commit by ossi: establish bi-directional mapping between mails and sync records. use it to merge the --renew case into the --new case.
M +1 -1 isync.h 1.49 M +53 -66 sync.c 1.59 --- isync/src/isync.h #1.48:1.49 @@ -119,5 +119,4 @@ typedef struct group_conf { #define M_DEAD (1<<1) /* expunged */ #define M_FLAGS (1<<2) /* flags fetched */ -#define M_PROCESSED (1<<3) /* registered in pair */ #define M_SYNCED (1<<4) /* already propagated */ #define M_EXPIRED (1<<5) /* kicked out by MaxMessages */ @@ -125,4 +124,5 @@ typedef struct group_conf { typedef struct message { struct message *next; + struct sync_rec *srec; /* string_list_t *keywords; */ size_t size; /* zero implies "not fetched" */ --- isync/src/sync.c #1.58:1.59 @@ -83,4 +83,5 @@ make_flags( int flags, char *buf ) #define S_DEL(ms) (1<<(2+(ms))) #define S_EXP_S (1<<4) +#define S_DONE (1<<6) typedef struct sync_rec { @@ -123,8 +124,9 @@ findmsgs( sync_rec_t *srecs, store_t *ct } } + msg->srec = 0; debug( "new\n" ); continue; found: - msg->status |= M_PROCESSED; + msg->srec = srec; if (srec->uid[1-t] >= 0) msg->status |= M_SYNCED; @@ -589,10 +591,9 @@ sync_boxes( store_t *ctx[], const char * for (nmsgs = 0, tmsg = ctx[1-t]->msgs; tmsg; tmsg = tmsg->next) - if (!(tmsg->status & M_PROCESSED)) { - if (chan->ops[t] & OP_NEW) { + if (tmsg->srec ? tmsg->srec->uid[t] < 0 && (chan->ops[t] & OP_RENEW) : (chan->ops[t] & OP_NEW)) { 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] ); - } else { + else { if ((tmsg->flags & F_FLAGGED) || !chan->stores[t]->max_size || tmsg->size <= chan->stores[t]->max_size) { debug( " %sing it\n", str_hl[t] ); @@ -612,23 +613,37 @@ sync_boxes( store_t *ctx[], const char * case DRV_STORE_BAD: return SYNC_BAD(t); default: return SYNC_FAIL; - case DRV_OK: tmsg->status |= M_SYNCED; break; + case DRV_OK: break; } } else { + if (tmsg->srec) { + debug( " -> not %sing - still too big\n", str_hl[t] ); + continue; + } debug( " not %sing - too big\n", str_hl[t] ); uid = -1; } + tmsg->status |= M_SYNCED; + if (tmsg->srec) { + srec = tmsg->srec; + Fprintf( jfp, "%c %d %d %d\n", "<>"[t], srec->uid[M], srec->uid[S], uid ); + } else { srec = nfmalloc( sizeof(*srec) ); - srec->uid[1-t] = tmsg->uid; - srec->uid[t] = uid; - srec->flags = tmsg->flags; - srec->status = 0; srec->next = 0; *srecadd = srec; srecadd = &srec->next; - Fprintf( jfp, "+ %d %d %u\n", srec->uid[M], srec->uid[S], srec->flags ); + srec->uid[1-t] = tmsg->uid; + } + srec->uid[t] = uid; + srec->flags = tmsg->flags; + srec->status = S_DONE; + if (tmsg->srec) + Fprintf( jfp, "* %d %d %u\n", srec->uid[M], srec->uid[S], srec->flags ); + else { + tmsg->srec = srec; if (maxuid[1-t] < tmsg->uid) { maxuid[1-t] = tmsg->uid; Fprintf( jfp, "%c %d\n", ")("[t], tmsg->uid ); } + Fprintf( jfp, "+ %d %d %u\n", srec->uid[M], srec->uid[S], srec->flags ); } } @@ -641,5 +656,5 @@ sync_boxes( store_t *ctx[], const char * Fprintf( jfp, "^\n" ); for (srec = recs; srec != *osrecadd; srec = srec->next) { - if (srec->status & S_DEAD) + if (srec->status & (S_DEAD|S_DONE)) continue; debug( "pair (%d,%d)\n", srec->uid[M], srec->uid[S] ); @@ -657,5 +672,5 @@ sync_boxes( store_t *ctx[], const char * for (t = 0; t < 2; t++) { - int uid, unex; + int unex; unsigned char sflags, aflags, dflags, rflags; @@ -683,36 +698,8 @@ sync_boxes( store_t *ctx[], const char * /* c.1) c.2) d.7) d.8) / b.1) b.2) d.2) d.3) */ ; - else if (srec->uid[t] < 0) { + else if (srec->uid[t] < 0) /* b.2) / c.2) */ - debug( " no %s yet\n", str_ms[t] ); - if (chan->ops[t] & OP_RENEW) { - if ((chan->ops[t] & OP_EXPUNGE) && (srec->msg[1-t]->flags & F_DELETED)) { - debug( " -> not %sing - would be expunged anyway\n", str_hl[t] ); - } else { - 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] ); - msgdata.flags = srec->msg[1-t]->flags; - 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_BOX_BAD: ret = SYNC_FAIL; goto finish; - default: /* ok */ break; - case DRV_OK: - srec->msg[1-t]->flags = msgdata.flags; - switch (driver[t]->store_msg( ctx[t], &msgdata, &uid )) { - case DRV_STORE_BAD: ret = SYNC_BAD(t); goto finish; - default: ret = SYNC_FAIL; goto finish; - case DRV_OK: - Fprintf( jfp, "%c %d %d %d\n", "<>"[t], srec->uid[M], srec->uid[S], uid ); - srec->uid[t] = uid; - srec->msg[1-t]->status |= M_SYNCED; - nflags = srec->msg[1-t]->flags; - } - } - } else { - debug( " -> not %sing - still too big\n", str_hl[t] ); - } - } - } - } else if (!del[t]) { + ; /* handled above */ + else if (!del[t]) { /* a) & b.3) / c.3) */ debug( " may %s\n", str_hl[t] ); ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642 _______________________________________________ isync-devel mailing list isync-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/isync-devel