Fossil SCM
Fix "fossil sync -u" failing with "bad command: uvigot" when an unversioned file is pushed and the outgoing message is already full, as it is after a large commit. The client now always sends a "uvfile" card; only a server may substitute "uvigot".
Commit
7266ff3e93e834161ba67de3a6baa214dbf35fbd2118dcb5be44b03372961598
Parent
ee8a2237f3ff041…
1 file changed
+12
-5
+12
-5
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -699,19 +699,26 @@ | ||
| 699 | 699 | ** |
| 700 | 700 | ** uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT |
| 701 | 701 | ** |
| 702 | 702 | ** If the noContent flag is set, omit the CONTENT and set the 0x0004 |
| 703 | 703 | ** flag in FLAGS. |
| 704 | +** | |
| 705 | +** A server that has already reached its send size limit sends a short | |
| 706 | +** "uvigot" card in place of the file, and the client asks again. A | |
| 707 | +** client must not do that, because a server does not accept "uvigot". | |
| 708 | +** So the client sets isClient and always gets a "uvfile" card. | |
| 704 | 709 | */ |
| 705 | 710 | static void send_unversioned_file( |
| 706 | 711 | Xfer *pXfer, /* Transfer context */ |
| 707 | 712 | const char *zName, /* Name of unversioned file to be sent */ |
| 708 | - int noContent /* True to omit the content */ | |
| 713 | + int noContent, /* True to omit the content */ | |
| 714 | + int isClient /* True if sending from client to server */ | |
| 709 | 715 | ){ |
| 710 | 716 | Stmt q1; |
| 717 | + int isFull = !isClient && (int)blob_size(pXfer->pOut)>=pXfer->mxSend; | |
| 711 | 718 | |
| 712 | - if( (int)blob_size(pXfer->pOut)>=pXfer->mxSend ) noContent = 1; | |
| 719 | + if( isFull ) noContent = 1; | |
| 713 | 720 | if( noContent ){ |
| 714 | 721 | db_prepare(&q1, |
| 715 | 722 | "SELECT mtime, hash, encoding, sz FROM unversioned WHERE name=%Q", |
| 716 | 723 | zName |
| 717 | 724 | ); |
| @@ -728,11 +735,11 @@ | ||
| 728 | 735 | if( pXfer->remoteVersion<20000 && db_column_bytes(&q1,1)>HNAME_LEN_SHA1 ){ |
| 729 | 736 | xfer_cannot_send_sha3_error(pXfer); |
| 730 | 737 | db_reset(&q1); |
| 731 | 738 | return; |
| 732 | 739 | } |
| 733 | - if( (int)blob_size(pXfer->pOut)>=pXfer->mxSend ){ | |
| 740 | + if( isFull ){ | |
| 734 | 741 | /* If we have already reached the send size limit, send a (short) |
| 735 | 742 | ** uvigot card rather than a uvfile card. This only happens on the |
| 736 | 743 | ** server side. The uvigot card will provoke the client to resend |
| 737 | 744 | ** another uvgimme on the next cycle. */ |
| 738 | 745 | blob_appendf(pXfer->pOut, "uvigot %s %lld %s %d\n", |
| @@ -1436,11 +1443,11 @@ | ||
| 1436 | 1443 | if( blob_eq(&xfer.aToken[0], "uvgimme") |
| 1437 | 1444 | && xfer.nToken==2 |
| 1438 | 1445 | && blob_is_filename(&xfer.aToken[1]) |
| 1439 | 1446 | ){ |
| 1440 | 1447 | if( g.perm.Read ){ |
| 1441 | - send_unversioned_file(&xfer, blob_str(&xfer.aToken[1]), 0); | |
| 1448 | + send_unversioned_file(&xfer, blob_str(&xfer.aToken[1]), 0, 0); | |
| 1442 | 1449 | } |
| 1443 | 1450 | }else |
| 1444 | 1451 | |
| 1445 | 1452 | /* igot HASH ?ISPRIVATE? |
| 1446 | 1453 | ** |
| @@ -2369,11 +2376,11 @@ | ||
| 2369 | 2376 | Stmt uvq; |
| 2370 | 2377 | int rc = SQLITE_OK; |
| 2371 | 2378 | db_prepare(&uvq, "SELECT name, mtimeOnly FROM uv_tosend"); |
| 2372 | 2379 | while( (rc = db_step(&uvq))==SQLITE_ROW ){ |
| 2373 | 2380 | const char *zName = db_column_text(&uvq, 0); |
| 2374 | - send_unversioned_file(&xfer, zName, db_column_int(&uvq,1)); | |
| 2381 | + send_unversioned_file(&xfer, zName, db_column_int(&uvq,1), 1); | |
| 2375 | 2382 | nCardSent++; |
| 2376 | 2383 | nArtifactSent++; |
| 2377 | 2384 | db_multi_exec("DELETE FROM uv_tosend WHERE name=%Q", zName); |
| 2378 | 2385 | if( syncFlags & SYNC_VERBOSE ){ |
| 2379 | 2386 | fossil_print("\rUnversioned-file sent: %s\n", zName); |
| 2380 | 2387 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -699,19 +699,26 @@ | |
| 699 | ** |
| 700 | ** uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT |
| 701 | ** |
| 702 | ** If the noContent flag is set, omit the CONTENT and set the 0x0004 |
| 703 | ** flag in FLAGS. |
| 704 | */ |
| 705 | static void send_unversioned_file( |
| 706 | Xfer *pXfer, /* Transfer context */ |
| 707 | const char *zName, /* Name of unversioned file to be sent */ |
| 708 | int noContent /* True to omit the content */ |
| 709 | ){ |
| 710 | Stmt q1; |
| 711 | |
| 712 | if( (int)blob_size(pXfer->pOut)>=pXfer->mxSend ) noContent = 1; |
| 713 | if( noContent ){ |
| 714 | db_prepare(&q1, |
| 715 | "SELECT mtime, hash, encoding, sz FROM unversioned WHERE name=%Q", |
| 716 | zName |
| 717 | ); |
| @@ -728,11 +735,11 @@ | |
| 728 | if( pXfer->remoteVersion<20000 && db_column_bytes(&q1,1)>HNAME_LEN_SHA1 ){ |
| 729 | xfer_cannot_send_sha3_error(pXfer); |
| 730 | db_reset(&q1); |
| 731 | return; |
| 732 | } |
| 733 | if( (int)blob_size(pXfer->pOut)>=pXfer->mxSend ){ |
| 734 | /* If we have already reached the send size limit, send a (short) |
| 735 | ** uvigot card rather than a uvfile card. This only happens on the |
| 736 | ** server side. The uvigot card will provoke the client to resend |
| 737 | ** another uvgimme on the next cycle. */ |
| 738 | blob_appendf(pXfer->pOut, "uvigot %s %lld %s %d\n", |
| @@ -1436,11 +1443,11 @@ | |
| 1436 | if( blob_eq(&xfer.aToken[0], "uvgimme") |
| 1437 | && xfer.nToken==2 |
| 1438 | && blob_is_filename(&xfer.aToken[1]) |
| 1439 | ){ |
| 1440 | if( g.perm.Read ){ |
| 1441 | send_unversioned_file(&xfer, blob_str(&xfer.aToken[1]), 0); |
| 1442 | } |
| 1443 | }else |
| 1444 | |
| 1445 | /* igot HASH ?ISPRIVATE? |
| 1446 | ** |
| @@ -2369,11 +2376,11 @@ | |
| 2369 | Stmt uvq; |
| 2370 | int rc = SQLITE_OK; |
| 2371 | db_prepare(&uvq, "SELECT name, mtimeOnly FROM uv_tosend"); |
| 2372 | while( (rc = db_step(&uvq))==SQLITE_ROW ){ |
| 2373 | const char *zName = db_column_text(&uvq, 0); |
| 2374 | send_unversioned_file(&xfer, zName, db_column_int(&uvq,1)); |
| 2375 | nCardSent++; |
| 2376 | nArtifactSent++; |
| 2377 | db_multi_exec("DELETE FROM uv_tosend WHERE name=%Q", zName); |
| 2378 | if( syncFlags & SYNC_VERBOSE ){ |
| 2379 | fossil_print("\rUnversioned-file sent: %s\n", zName); |
| 2380 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -699,19 +699,26 @@ | |
| 699 | ** |
| 700 | ** uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT |
| 701 | ** |
| 702 | ** If the noContent flag is set, omit the CONTENT and set the 0x0004 |
| 703 | ** flag in FLAGS. |
| 704 | ** |
| 705 | ** A server that has already reached its send size limit sends a short |
| 706 | ** "uvigot" card in place of the file, and the client asks again. A |
| 707 | ** client must not do that, because a server does not accept "uvigot". |
| 708 | ** So the client sets isClient and always gets a "uvfile" card. |
| 709 | */ |
| 710 | static void send_unversioned_file( |
| 711 | Xfer *pXfer, /* Transfer context */ |
| 712 | const char *zName, /* Name of unversioned file to be sent */ |
| 713 | int noContent, /* True to omit the content */ |
| 714 | int isClient /* True if sending from client to server */ |
| 715 | ){ |
| 716 | Stmt q1; |
| 717 | int isFull = !isClient && (int)blob_size(pXfer->pOut)>=pXfer->mxSend; |
| 718 | |
| 719 | if( isFull ) noContent = 1; |
| 720 | if( noContent ){ |
| 721 | db_prepare(&q1, |
| 722 | "SELECT mtime, hash, encoding, sz FROM unversioned WHERE name=%Q", |
| 723 | zName |
| 724 | ); |
| @@ -728,11 +735,11 @@ | |
| 735 | if( pXfer->remoteVersion<20000 && db_column_bytes(&q1,1)>HNAME_LEN_SHA1 ){ |
| 736 | xfer_cannot_send_sha3_error(pXfer); |
| 737 | db_reset(&q1); |
| 738 | return; |
| 739 | } |
| 740 | if( isFull ){ |
| 741 | /* If we have already reached the send size limit, send a (short) |
| 742 | ** uvigot card rather than a uvfile card. This only happens on the |
| 743 | ** server side. The uvigot card will provoke the client to resend |
| 744 | ** another uvgimme on the next cycle. */ |
| 745 | blob_appendf(pXfer->pOut, "uvigot %s %lld %s %d\n", |
| @@ -1436,11 +1443,11 @@ | |
| 1443 | if( blob_eq(&xfer.aToken[0], "uvgimme") |
| 1444 | && xfer.nToken==2 |
| 1445 | && blob_is_filename(&xfer.aToken[1]) |
| 1446 | ){ |
| 1447 | if( g.perm.Read ){ |
| 1448 | send_unversioned_file(&xfer, blob_str(&xfer.aToken[1]), 0, 0); |
| 1449 | } |
| 1450 | }else |
| 1451 | |
| 1452 | /* igot HASH ?ISPRIVATE? |
| 1453 | ** |
| @@ -2369,11 +2376,11 @@ | |
| 2376 | Stmt uvq; |
| 2377 | int rc = SQLITE_OK; |
| 2378 | db_prepare(&uvq, "SELECT name, mtimeOnly FROM uv_tosend"); |
| 2379 | while( (rc = db_step(&uvq))==SQLITE_ROW ){ |
| 2380 | const char *zName = db_column_text(&uvq, 0); |
| 2381 | send_unversioned_file(&xfer, zName, db_column_int(&uvq,1), 1); |
| 2382 | nCardSent++; |
| 2383 | nArtifactSent++; |
| 2384 | db_multi_exec("DELETE FROM uv_tosend WHERE name=%Q", zName); |
| 2385 | if( syncFlags & SYNC_VERBOSE ){ |
| 2386 | fossil_print("\rUnversioned-file sent: %s\n", zName); |
| 2387 |