CVS commit by ossi: 

move fetching new messages in front of syncing old entries. this alone
does not buy us a whole lot ...


  M +58 -56    sync.c   1.57


--- isync/src/sync.c  #1.56:1.57
@@ -181,5 +181,5 @@ sync_boxes( store_t *ctx[], const char *
        driver_t *driver[2];
        message_t *tmsg;
-       sync_rec_t *recs, *srec, **srecadd, *nsrec;
+       sync_rec_t *recs, *srec, **srecadd, *nsrec, **osrecadd;
        char *dname, *jname, *nname, *lname, *s, *cmname, *csname;
        FILE *dfp, *jfp, *nfp;
@@ -582,7 +582,63 @@ sync_boxes( store_t *ctx[], const char *
 
        info( "Synchronizing...\n" );
+
+       debug( "synchronizing new entries\n" );
+       osrecadd = srecadd;
+       for (t = 0; t < 2; t++) {
+               int nmsgs, uid;
+
+               for (nmsgs = 0, tmsg = ctx[1-t]->msgs; tmsg; tmsg = tmsg->next)
+                       if (!(tmsg->status & M_PROCESSED)) {
+                               if (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)) {
+                                               debug( "  not %sing - would be 
expunged anyway\n", str_hl[t] );
+                                       } 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] );
+                                                       if (!nmsgs)
+                                                               info( t ? 
"Pulling new messages..." : "Pushing new messages..." );
+                                                       else
+                                                               infoc( '.' );
+                                                       nmsgs++;
+                                                       msgdata.flags = 
tmsg->flags;
+                                                       switch 
(driver[1-t]->fetch_msg( ctx[1-t], tmsg, &msgdata )) {
+                                                       case DRV_STORE_BAD: 
return SYNC_BAD(1-t);
+                                                       case DRV_BOX_BAD: 
return SYNC_FAIL;
+                                                       case DRV_MSG_BAD: /* ok 
*/ continue;
+                                                       }
+                                                       tmsg->flags = 
msgdata.flags;
+                                                       switch 
(driver[t]->store_msg( ctx[t], &msgdata, &uid )) {
+                                                       case DRV_STORE_BAD: 
return SYNC_BAD(t);
+                                                       default: return 
SYNC_FAIL;
+                                                       case DRV_OK: 
tmsg->status |= M_SYNCED; break;
+                                                       }
+                                               } else {
+                                                       debug( "  not %sing - 
too big\n", str_hl[t] );
+                                                       uid = -1;
+                                               }
+                                               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 );
+                                               if (maxuid[1-t] < tmsg->uid) {
+                                                       maxuid[1-t] = tmsg->uid;
+                                                       Fprintf( jfp, "%c 
%d\n", ")("[t], tmsg->uid );
+                                               }
+                                       }
+                               }
+                       }
+               if (nmsgs)
+                       info( " %d messages\n", nmsgs );
+       }
+
        debug( "synchronizing old entries\n" );
        Fprintf( jfp, "^\n" );
-       for (srec = recs; srec; srec = srec->next) {
+       for (srec = recs; srec != *osrecadd; srec = srec->next) {
                if (srec->status & S_DEAD)
                        continue;
@@ -716,58 +772,4 @@ sync_boxes( store_t *ctx[], const char *
        }
 
-       debug( "synchronizing new entries\n" );
-       for (t = 0; t < 2; t++) {
-               int nmsgs, uid;
-
-               for (nmsgs = 0, tmsg = ctx[1-t]->msgs; tmsg; tmsg = tmsg->next)
-                       if (!(tmsg->status & M_PROCESSED)) {
-                               if (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)) {
-                                               debug( "  not %sing - would be 
expunged anyway\n", str_hl[t] );
-                                       } 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] );
-                                                       if (!nmsgs)
-                                                               info( t ? 
"Pulling new messages..." : "Pushing new messages..." );
-                                                       else
-                                                               infoc( '.' );
-                                                       nmsgs++;
-                                                       msgdata.flags = 
tmsg->flags;
-                                                       switch 
(driver[1-t]->fetch_msg( ctx[1-t], tmsg, &msgdata )) {
-                                                       case DRV_STORE_BAD: 
return SYNC_BAD(1-t);
-                                                       case DRV_BOX_BAD: 
return SYNC_FAIL;
-                                                       case DRV_MSG_BAD: /* ok 
*/ continue;
-                                                       }
-                                                       tmsg->flags = 
msgdata.flags;
-                                                       switch 
(driver[t]->store_msg( ctx[t], &msgdata, &uid )) {
-                                                       case DRV_STORE_BAD: 
return SYNC_BAD(t);
-                                                       default: return 
SYNC_FAIL;
-                                                       case DRV_OK: 
tmsg->status |= M_SYNCED; break;
-                                                       }
-                                               } else {
-                                                       debug( "  not %sing - 
too big\n", str_hl[t] );
-                                                       uid = -1;
-                                               }
-                                               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 );
-                                               if (maxuid[1-t] < tmsg->uid) {
-                                                       maxuid[1-t] = tmsg->uid;
-                                                       Fprintf( jfp, "%c 
%d\n", ")("[t], tmsg->uid );
-                                               }
-                                       }
-                               }
-                       }
-               if (nmsgs)
-                       info( " %d messages\n", nmsgs );
-       }
-
        if ((chan->ops[S] & (OP_NEW|OP_RENEW)) && chan->max_messages) {
                debug( "expiring excess entries\n" );




-------------------------------------------------------
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

Reply via email to