Fossil

Check-in [e5b8eb12]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix the server-side sync operation so that it will not generate a delta loop when a file changes from its original state through two or more intermediate states and back to its original state and all versions of the file attempt to sync in a single transaction.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e5b8eb12352f11fb0082c46818e25eaa7a674f13
User & Date: drh 2012-11-17 19:16:15
Context
2012-11-19
13:54
Make no transformation to wiki hyperlinks (text inside [..]) if the content is not a valid hyperlink. Formerly, the faulty hyperlink would be displayed within <span class="brokenlink">..<span>. check-in: 90676f48 user: drh tags: trunk
2012-11-17
20:19
merge trunk Closed-Leaf check-in: 7e7dcdd2 user: jan.nijtmans tags: convert_before_commit
19:16
Fix the server-side sync operation so that it will not generate a delta loop when a file changes from its original state through two or more intermediate states and back to its original state and all versions of the file attempt to sync in a single transaction. check-in: e5b8eb12 user: drh tags: trunk
19:07
Avoid the <nobr> tag in generated HTML. check-in: 8ea929ca user: drh tags: trunk
15:03
Only show the "pull only - not authorized to push" message once when syncing with a repo for which there is read-only permission. Closed-Leaf check-in: 6cc26220 user: drh tags: fix-sync-delta-loop
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/xfer.c.

271
272
273
274
275
276
277
278
279
280
281
282

283
284
285
286
287
288
289
290
291
292
293
...
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
....
1657
1658
1659
1660
1661
1662
1663




1664
1665
1666
1667
1668
1669
1670
1671
  int isPrivate,          /* True if rid is a private artifact */
  Blob *pContent,         /* The content of the file to send */
  Blob *pUuid             /* The UUID of the file to send */
){
  static const char *const azQuery[] = {
    "SELECT pid FROM plink x"
    " WHERE cid=%d"
    "   AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)"
    "   AND NOT EXISTS(SELECT 1 FROM plink y"
                      " WHERE y.pid=x.cid AND y.cid=x.pid)",

    "SELECT pid FROM mlink x"

    " WHERE fid=%d"
    "   AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)"
    "   AND NOT EXISTS(SELECT 1 FROM mlink y"
                     "  WHERE y.pid=x.fid AND y.fid=x.pid)"
  };
  int i;
  Blob src, delta;
  int size = 0;
  int srcId = 0;

  for(i=0; srcId==0 && i<count(azQuery); i++){
................................................................................
    blob_delta_create(&src, pContent, &delta);
    size = blob_size(&delta);
    if( size>=blob_size(pContent)-50 ){
      size = 0;
    }else if( uuid_is_shunned(zUuid) ){
      size = 0;
    }else{
      if( isPrivate ) blob_append(pXfer->pOut, "private\n", -1);
      blob_appendf(pXfer->pOut, "file %b %s %d\n", pUuid, zUuid, size);
      blob_append(pXfer->pOut, blob_buffer(&delta), size);
    }
    blob_reset(&delta);
    free(zUuid);
    blob_reset(&src);
  }
................................................................................
      **
      ** If the "login failed" message is seen, clear the sync password prior
      ** to the next cycle.
      */        
      if( blob_eq(&xfer.aToken[0],"message") && xfer.nToken==2 ){
        char *zMsg = blob_terminate(&xfer.aToken[1]);
        defossilize(zMsg);




        if( zMsg ) fossil_print("\rServer says: %s\n", zMsg);
      }else

      /*    pragma NAME VALUE...
      **
      ** The server can send pragmas to try to convey meta-information to
      ** the client.  These are informational only.  Unknown pragmas are 
      ** silently ignored.







|
<
<
|
<
>


<
<







 







|







 







>
>
>
>
|







271
272
273
274
275
276
277
278


279

280
281
282


283
284
285
286
287
288
289
...
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
....
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
  int isPrivate,          /* True if rid is a private artifact */
  Blob *pContent,         /* The content of the file to send */
  Blob *pUuid             /* The UUID of the file to send */
){
  static const char *const azQuery[] = {
    "SELECT pid FROM plink x"
    " WHERE cid=%d"
    "   AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)",


    

    "SELECT pid, min(mtime) FROM mlink, event ON mlink.mid=event.objid"
    " WHERE fid=%d"
    "   AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)"


  };
  int i;
  Blob src, delta;
  int size = 0;
  int srcId = 0;

  for(i=0; srcId==0 && i<count(azQuery); i++){
................................................................................
    blob_delta_create(&src, pContent, &delta);
    size = blob_size(&delta);
    if( size>=blob_size(pContent)-50 ){
      size = 0;
    }else if( uuid_is_shunned(zUuid) ){
      size = 0;
    }else{
       if( isPrivate ) blob_append(pXfer->pOut, "private\n", -1);
      blob_appendf(pXfer->pOut, "file %b %s %d\n", pUuid, zUuid, size);
      blob_append(pXfer->pOut, blob_buffer(&delta), size);
    }
    blob_reset(&delta);
    free(zUuid);
    blob_reset(&src);
  }
................................................................................
      **
      ** If the "login failed" message is seen, clear the sync password prior
      ** to the next cycle.
      */        
      if( blob_eq(&xfer.aToken[0],"message") && xfer.nToken==2 ){
        char *zMsg = blob_terminate(&xfer.aToken[1]);
        defossilize(zMsg);
        if( pushFlag && zMsg && strglob("pull only *", zMsg) ){
          pushFlag = 0;
          zMsg = 0;
        }
        fossil_print("\rServer says: %s\n", zMsg);
      }else

      /*    pragma NAME VALUE...
      **
      ** The server can send pragmas to try to convey meta-information to
      ** the client.  These are informational only.  Unknown pragmas are 
      ** silently ignored.