Diff
Not logged in

Differences From:

File src/xfer.c part of check-in [651c75c5b7] - merge trunk into creole by robert on 2009-10-05 10:08:05. Also file src/xfer.c part of check-in [469efd6a7c] - Disable the check of the "server-code" on a sync. This means that two repositories with the same "server-code" can sync with each other, which allows a repository to be copied using an ordinary file copy, and without having to run clone. by drh on 2009-10-01 14:47:54. [view]

To:

File src/xfer.c part of check-in [0690aa18a4] - Better error messages when "sync" fails due to server problems. Ticket bfb8427cdd5 by drh on 2009-11-11 14:59:09. [view]

@@ -923,9 +923,10 @@
   int configRcvMask,      /* Receive these configuration items */
   int configSendMask      /* Send these configuration items */
 ){
   int go = 1;             /* Loop until zero */
-  int nCard = 0;          /* Number of cards sent or received */
+  int nCardSent = 0;      /* Number of cards sent */
+  int nCardRcvd = 0;      /* Number of cards received */
   int nCycle = 0;         /* Number of round trips to the server */
   int size;               /* Size of a config value */
   int nFileSend = 0;
   int origConfigRcvMask;  /* Original value of configRcvMask */
@@ -969,17 +970,17 @@
   if( cloneFlag ){
     blob_appendf(&send, "clone\n");
     pushFlag = 0;
     pullFlag = 0;
-    nCard++;
+    nCardSent++;
     /* TBD: Request all transferable configuration values */
   }else if( pullFlag ){
     blob_appendf(&send, "pull %s %s\n", zSCode, zPCode);
-    nCard++;
+    nCardSent++;
   }
   if( pushFlag ){
     blob_appendf(&send, "push %s %s\n", zSCode, zPCode);
-    nCard++;
+    nCardSent++;
   }
   manifest_crosslink_begin();
   printf(zLabelFormat, "", "Bytes", "Cards", "Artifacts", "Deltas");
 
@@ -1002,9 +1003,9 @@
       request_phantoms(&xfer, mxPhantomReq);
     }
     if( pushFlag ){
       send_unsent(&xfer);
-      nCard += send_unclustered(&xfer);
+      nCardSent += send_unclustered(&xfer);
     }
 
     /* Send configuration parameter requests */
     if( configRcvMask ){
@@ -1012,9 +1013,9 @@
       zName = configure_first_name(configRcvMask);
       while( zName ){
         blob_appendf(&send, "reqconfig %s\n", zName);
         zName = configure_next_name(configRcvMask);
-        nCard++;
+        nCardSent++;
       }
       if( configRcvMask & (CONFIGSET_USER|CONFIGSET_TKT) ){
         configure_prepare_to_receive(0);
       }
@@ -1027,9 +1028,9 @@
       zName = configure_first_name(configSendMask);
       while( zName ){
         send_config_card(&xfer, zName);
         zName = configure_next_name(configSendMask);
-        nCard++;
+        nCardSent++;
       }
       configSendMask = 0;
     }
 
@@ -1040,11 +1041,12 @@
 
     /* Exchange messages with the server */
     nFileSend = xfer.nFileSent + xfer.nDeltaSent;
     printf(zValueFormat, "Send:",
-            blob_size(&send), nCard+xfer.nGimmeSent+xfer.nIGotSent,
+            blob_size(&send), nCardSent+xfer.nGimmeSent+xfer.nIGotSent,
             xfer.nFileSent, xfer.nDeltaSent);
-    nCard = 0;
+    nCardSent = 0;
+    nCardRcvd = 0;
     xfer.nFileSent = 0;
     xfer.nDeltaSent = 0;
     xfer.nGimmeSent = 0;
     fflush(stdout);
@@ -1055,13 +1057,13 @@
     ** sent) by beginning with the pull or push cards
     */
     if( pullFlag ){
       blob_appendf(&send, "pull %s %s\n", zSCode, zPCode);
-      nCard++;
+      nCardSent++;
     }
     if( pushFlag ){
       blob_appendf(&send, "push %s %s\n", zSCode, zPCode);
-      nCard++;
+      nCardSent++;
     }
 
     /* Process the reply that came back from the server */
     while( blob_line(&recv, &xfer.line) ){
@@ -1068,10 +1070,10 @@
       if( blob_buffer(&xfer.line)[0]=='#' ){
         continue;
       }
       xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
-      nCard++;
-      printf("\r%d", nCard);
+      nCardRcvd++;
+      printf("\r%d", nCardRcvd);
       fflush(stdout);
 
       /*   file UUID SIZE \n CONTENT
       **   file UUID DELTASRC SIZE \n CONTENT
@@ -1139,9 +1141,9 @@
           zPCode = mprintf("%b", &xfer.aToken[2]);
           db_set("project-code", zPCode, 0);
         }
         blob_appendf(&send, "clone\n");
-        nCard++;
+        nCardSent++;
       }else
 
       /*   config NAME SIZE \n CONTENT
       **
@@ -1179,9 +1181,9 @@
             */
             db_multi_exec("%s", blob_str(&content));
           }
         }
-        nCard++;
+        nCardSent++;
         blob_reset(&content);
         blob_seek(xfer.pIn, 1, BLOB_SEEK_CUR);
       }else
 
@@ -1205,9 +1207,9 @@
       */
       if( blob_eq(&xfer.aToken[0],"message") && xfer.nToken==2 ){
         char *zMsg = blob_terminate(&xfer.aToken[1]);
         defossilize(zMsg);
-        printf("Server says: %s\n", zMsg);
+        printf("\rServer says: %s\n", zMsg);
       }else
 
       /*   error MESSAGE
       **
@@ -1216,8 +1218,9 @@
       if( blob_eq(&xfer.aToken[0],"error") && xfer.nToken==2 ){
         char *zMsg = blob_terminate(&xfer.aToken[1]);
         defossilize(zMsg);
         blob_appendf(&xfer.err, "server says: %s", zMsg);
+        printf("Server Error: %s\n", zMsg);
       }else
 
       /* Unknown message */
       {
@@ -1239,11 +1242,13 @@
     if( origConfigRcvMask & (CONFIGSET_TKT|CONFIGSET_USER) ){
       configure_finalize_receive();
     }
     origConfigRcvMask = 0;
-    printf(zValueFormat, "Received:",
-            blob_size(&recv), nCard,
-            xfer.nFileRcvd, xfer.nDeltaRcvd + xfer.nDanglingFile);
+    if( nCardRcvd>0 ){
+      printf(zValueFormat, "Received:",
+              blob_size(&recv), nCardRcvd,
+              xfer.nFileRcvd, xfer.nDeltaRcvd + xfer.nDanglingFile);
+    }
     blob_reset(&recv);
     nCycle++;
     go = 0;
 
@@ -1255,9 +1260,9 @@
       go = 1;
       mxPhantomReq = nFileRecv*2;
       if( mxPhantomReq<200 ) mxPhantomReq = 200;
     }
-    nCard = 0;
+    nCardRcvd = 0;
     xfer.nFileRcvd = 0;
     xfer.nDeltaRcvd = 0;
     xfer.nDanglingFile = 0;