Fossil SCM
Add the undocumented --heavy option to the sync, push, and pull commands. The --heavy option causes all known artifacts to be reported using "igot" cards and can be used to overcome a sync-stall.
Commit
05ba15e448d7676d88c332cc5cd47298aa57f060
Parent
81f9791c017cab6…
2 files changed
+3
+36
-6
+3
| --- src/sync.c | ||
| +++ src/sync.c | ||
| @@ -93,10 +93,13 @@ | ||
| 93 | 93 | if( find_option("private",0,0)!=0 ){ |
| 94 | 94 | *pSyncFlags |= SYNC_PRIVATE; |
| 95 | 95 | } |
| 96 | 96 | if( find_option("verbose","v",0)!=0 ){ |
| 97 | 97 | *pSyncFlags |= SYNC_VERBOSE; |
| 98 | + } | |
| 99 | + if( find_option("heavy",0,0)!=0 ){ | |
| 100 | + *pSyncFlags |= SYNC_RESYNC; | |
| 98 | 101 | } |
| 99 | 102 | url_proxy_options(); |
| 100 | 103 | db_find_and_open_repository(0, 0); |
| 101 | 104 | db_open_config(0); |
| 102 | 105 | if( g.argc==2 ){ |
| 103 | 106 |
| --- src/sync.c | |
| +++ src/sync.c | |
| @@ -93,10 +93,13 @@ | |
| 93 | if( find_option("private",0,0)!=0 ){ |
| 94 | *pSyncFlags |= SYNC_PRIVATE; |
| 95 | } |
| 96 | if( find_option("verbose","v",0)!=0 ){ |
| 97 | *pSyncFlags |= SYNC_VERBOSE; |
| 98 | } |
| 99 | url_proxy_options(); |
| 100 | db_find_and_open_repository(0, 0); |
| 101 | db_open_config(0); |
| 102 | if( g.argc==2 ){ |
| 103 |
| --- src/sync.c | |
| +++ src/sync.c | |
| @@ -93,10 +93,13 @@ | |
| 93 | if( find_option("private",0,0)!=0 ){ |
| 94 | *pSyncFlags |= SYNC_PRIVATE; |
| 95 | } |
| 96 | if( find_option("verbose","v",0)!=0 ){ |
| 97 | *pSyncFlags |= SYNC_VERBOSE; |
| 98 | } |
| 99 | if( find_option("heavy",0,0)!=0 ){ |
| 100 | *pSyncFlags |= SYNC_RESYNC; |
| 101 | } |
| 102 | url_proxy_options(); |
| 103 | db_find_and_open_repository(0, 0); |
| 104 | db_open_config(0); |
| 105 | if( g.argc==2 ){ |
| 106 |
+36
-6
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -46,10 +46,11 @@ | ||
| 46 | 46 | int nDeltaSent; /* Number of deltas sent */ |
| 47 | 47 | int nFileRcvd; /* Number of files received */ |
| 48 | 48 | int nDeltaRcvd; /* Number of deltas received */ |
| 49 | 49 | int nDanglingFile; /* Number of dangling deltas received */ |
| 50 | 50 | int mxSend; /* Stop sending "file" with pOut reaches this size */ |
| 51 | + int resync; /* Send igot cards for all holdings */ | |
| 51 | 52 | u8 syncPrivate; /* True to enable syncing private content */ |
| 52 | 53 | u8 nextIsPrivate; /* If true, next "file" received is a private */ |
| 53 | 54 | time_t maxTime; /* Time when this transfer should be finished */ |
| 54 | 55 | }; |
| 55 | 56 | |
| @@ -736,21 +737,37 @@ | ||
| 736 | 737 | ** Return the number of cards sent. |
| 737 | 738 | */ |
| 738 | 739 | static int send_unclustered(Xfer *pXfer){ |
| 739 | 740 | Stmt q; |
| 740 | 741 | int cnt = 0; |
| 741 | - db_prepare(&q, | |
| 742 | - "SELECT uuid FROM unclustered JOIN blob USING(rid)" | |
| 743 | - " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" | |
| 744 | - " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)" | |
| 745 | - " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)" | |
| 746 | - ); | |
| 742 | + if( pXfer->resync ){ | |
| 743 | + db_prepare(&q, | |
| 744 | + "SELECT uuid, rid FROM blob" | |
| 745 | + " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" | |
| 746 | + " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)" | |
| 747 | + " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)" | |
| 748 | + " AND blob.rid<=%d" | |
| 749 | + " ORDER BY blob.rid DESC", | |
| 750 | + pXfer->resync | |
| 751 | + ); | |
| 752 | + }else{ | |
| 753 | + db_prepare(&q, | |
| 754 | + "SELECT uuid FROM unclustered JOIN blob USING(rid)" | |
| 755 | + " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" | |
| 756 | + " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)" | |
| 757 | + " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)" | |
| 758 | + ); | |
| 759 | + } | |
| 747 | 760 | while( db_step(&q)==SQLITE_ROW ){ |
| 748 | 761 | blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0)); |
| 749 | 762 | cnt++; |
| 763 | + if( pXfer->resync && pXfer->mxSend<blob_size(pXfer->pOut) ){ | |
| 764 | + pXfer->resync = db_column_int(&q, 1)-1; | |
| 765 | + } | |
| 750 | 766 | } |
| 751 | 767 | db_finalize(&q); |
| 768 | + if( cnt==0 ) pXfer->resync = 0; | |
| 752 | 769 | return cnt; |
| 753 | 770 | } |
| 754 | 771 | |
| 755 | 772 | /* |
| 756 | 773 | ** Send an igot message for every artifact. |
| @@ -1195,10 +1212,17 @@ | ||
| 1195 | 1212 | server_private_xfer_not_authorized(); |
| 1196 | 1213 | }else{ |
| 1197 | 1214 | xfer.syncPrivate = 1; |
| 1198 | 1215 | } |
| 1199 | 1216 | } |
| 1217 | + /* pragma send-catalog | |
| 1218 | + ** | |
| 1219 | + ** Send igot cards for all known artifacts. | |
| 1220 | + */ | |
| 1221 | + if( blob_eq(&xfer.aToken[1], "send-catalog") ){ | |
| 1222 | + xfer.resync = 0x7fffffff; | |
| 1223 | + } | |
| 1200 | 1224 | }else |
| 1201 | 1225 | |
| 1202 | 1226 | /* Unknown message |
| 1203 | 1227 | */ |
| 1204 | 1228 | { |
| @@ -1292,10 +1316,11 @@ | ||
| 1292 | 1316 | #define SYNC_PUSH 0x0001 |
| 1293 | 1317 | #define SYNC_PULL 0x0002 |
| 1294 | 1318 | #define SYNC_CLONE 0x0004 |
| 1295 | 1319 | #define SYNC_PRIVATE 0x0008 |
| 1296 | 1320 | #define SYNC_VERBOSE 0x0010 |
| 1321 | +#define SYNC_RESYNC 0x0020 | |
| 1297 | 1322 | #endif |
| 1298 | 1323 | |
| 1299 | 1324 | /* |
| 1300 | 1325 | ** Sync to the host identified in g.urlName and g.urlPath. This |
| 1301 | 1326 | ** routine is called by the client. |
| @@ -1380,15 +1405,20 @@ | ||
| 1380 | 1405 | zOpType = "Clone"; |
| 1381 | 1406 | }else if( syncFlags & SYNC_PULL ){ |
| 1382 | 1407 | blob_appendf(&send, "pull %s %s\n", zSCode, zPCode); |
| 1383 | 1408 | nCardSent++; |
| 1384 | 1409 | zOpType = (syncFlags & SYNC_PUSH)?"Sync":"Pull"; |
| 1410 | + if( (syncFlags & SYNC_RESYNC)!=0 && nCycle<2 ){ | |
| 1411 | + blob_appendf(&send, "pragma send-catalog\n"); | |
| 1412 | + nCardSent++; | |
| 1413 | + } | |
| 1385 | 1414 | } |
| 1386 | 1415 | if( syncFlags & SYNC_PUSH ){ |
| 1387 | 1416 | blob_appendf(&send, "push %s %s\n", zSCode, zPCode); |
| 1388 | 1417 | nCardSent++; |
| 1389 | 1418 | if( (syncFlags & SYNC_PULL)==0 ) zOpType = "Push"; |
| 1419 | + if( (syncFlags & SYNC_RESYNC)!=0 ) xfer.resync = 0x7fffffff; | |
| 1390 | 1420 | } |
| 1391 | 1421 | manifest_crosslink_begin(); |
| 1392 | 1422 | transport_global_startup(); |
| 1393 | 1423 | if( syncFlags & SYNC_VERBOSE ){ |
| 1394 | 1424 | fossil_print(zLabelFormat, "", "Bytes", "Cards", "Artifacts", "Deltas"); |
| 1395 | 1425 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -46,10 +46,11 @@ | |
| 46 | int nDeltaSent; /* Number of deltas sent */ |
| 47 | int nFileRcvd; /* Number of files received */ |
| 48 | int nDeltaRcvd; /* Number of deltas received */ |
| 49 | int nDanglingFile; /* Number of dangling deltas received */ |
| 50 | int mxSend; /* Stop sending "file" with pOut reaches this size */ |
| 51 | u8 syncPrivate; /* True to enable syncing private content */ |
| 52 | u8 nextIsPrivate; /* If true, next "file" received is a private */ |
| 53 | time_t maxTime; /* Time when this transfer should be finished */ |
| 54 | }; |
| 55 | |
| @@ -736,21 +737,37 @@ | |
| 736 | ** Return the number of cards sent. |
| 737 | */ |
| 738 | static int send_unclustered(Xfer *pXfer){ |
| 739 | Stmt q; |
| 740 | int cnt = 0; |
| 741 | db_prepare(&q, |
| 742 | "SELECT uuid FROM unclustered JOIN blob USING(rid)" |
| 743 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" |
| 744 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)" |
| 745 | " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)" |
| 746 | ); |
| 747 | while( db_step(&q)==SQLITE_ROW ){ |
| 748 | blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0)); |
| 749 | cnt++; |
| 750 | } |
| 751 | db_finalize(&q); |
| 752 | return cnt; |
| 753 | } |
| 754 | |
| 755 | /* |
| 756 | ** Send an igot message for every artifact. |
| @@ -1195,10 +1212,17 @@ | |
| 1195 | server_private_xfer_not_authorized(); |
| 1196 | }else{ |
| 1197 | xfer.syncPrivate = 1; |
| 1198 | } |
| 1199 | } |
| 1200 | }else |
| 1201 | |
| 1202 | /* Unknown message |
| 1203 | */ |
| 1204 | { |
| @@ -1292,10 +1316,11 @@ | |
| 1292 | #define SYNC_PUSH 0x0001 |
| 1293 | #define SYNC_PULL 0x0002 |
| 1294 | #define SYNC_CLONE 0x0004 |
| 1295 | #define SYNC_PRIVATE 0x0008 |
| 1296 | #define SYNC_VERBOSE 0x0010 |
| 1297 | #endif |
| 1298 | |
| 1299 | /* |
| 1300 | ** Sync to the host identified in g.urlName and g.urlPath. This |
| 1301 | ** routine is called by the client. |
| @@ -1380,15 +1405,20 @@ | |
| 1380 | zOpType = "Clone"; |
| 1381 | }else if( syncFlags & SYNC_PULL ){ |
| 1382 | blob_appendf(&send, "pull %s %s\n", zSCode, zPCode); |
| 1383 | nCardSent++; |
| 1384 | zOpType = (syncFlags & SYNC_PUSH)?"Sync":"Pull"; |
| 1385 | } |
| 1386 | if( syncFlags & SYNC_PUSH ){ |
| 1387 | blob_appendf(&send, "push %s %s\n", zSCode, zPCode); |
| 1388 | nCardSent++; |
| 1389 | if( (syncFlags & SYNC_PULL)==0 ) zOpType = "Push"; |
| 1390 | } |
| 1391 | manifest_crosslink_begin(); |
| 1392 | transport_global_startup(); |
| 1393 | if( syncFlags & SYNC_VERBOSE ){ |
| 1394 | fossil_print(zLabelFormat, "", "Bytes", "Cards", "Artifacts", "Deltas"); |
| 1395 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -46,10 +46,11 @@ | |
| 46 | int nDeltaSent; /* Number of deltas sent */ |
| 47 | int nFileRcvd; /* Number of files received */ |
| 48 | int nDeltaRcvd; /* Number of deltas received */ |
| 49 | int nDanglingFile; /* Number of dangling deltas received */ |
| 50 | int mxSend; /* Stop sending "file" with pOut reaches this size */ |
| 51 | int resync; /* Send igot cards for all holdings */ |
| 52 | u8 syncPrivate; /* True to enable syncing private content */ |
| 53 | u8 nextIsPrivate; /* If true, next "file" received is a private */ |
| 54 | time_t maxTime; /* Time when this transfer should be finished */ |
| 55 | }; |
| 56 | |
| @@ -736,21 +737,37 @@ | |
| 737 | ** Return the number of cards sent. |
| 738 | */ |
| 739 | static int send_unclustered(Xfer *pXfer){ |
| 740 | Stmt q; |
| 741 | int cnt = 0; |
| 742 | if( pXfer->resync ){ |
| 743 | db_prepare(&q, |
| 744 | "SELECT uuid, rid FROM blob" |
| 745 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" |
| 746 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)" |
| 747 | " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)" |
| 748 | " AND blob.rid<=%d" |
| 749 | " ORDER BY blob.rid DESC", |
| 750 | pXfer->resync |
| 751 | ); |
| 752 | }else{ |
| 753 | db_prepare(&q, |
| 754 | "SELECT uuid FROM unclustered JOIN blob USING(rid)" |
| 755 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" |
| 756 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)" |
| 757 | " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)" |
| 758 | ); |
| 759 | } |
| 760 | while( db_step(&q)==SQLITE_ROW ){ |
| 761 | blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0)); |
| 762 | cnt++; |
| 763 | if( pXfer->resync && pXfer->mxSend<blob_size(pXfer->pOut) ){ |
| 764 | pXfer->resync = db_column_int(&q, 1)-1; |
| 765 | } |
| 766 | } |
| 767 | db_finalize(&q); |
| 768 | if( cnt==0 ) pXfer->resync = 0; |
| 769 | return cnt; |
| 770 | } |
| 771 | |
| 772 | /* |
| 773 | ** Send an igot message for every artifact. |
| @@ -1195,10 +1212,17 @@ | |
| 1212 | server_private_xfer_not_authorized(); |
| 1213 | }else{ |
| 1214 | xfer.syncPrivate = 1; |
| 1215 | } |
| 1216 | } |
| 1217 | /* pragma send-catalog |
| 1218 | ** |
| 1219 | ** Send igot cards for all known artifacts. |
| 1220 | */ |
| 1221 | if( blob_eq(&xfer.aToken[1], "send-catalog") ){ |
| 1222 | xfer.resync = 0x7fffffff; |
| 1223 | } |
| 1224 | }else |
| 1225 | |
| 1226 | /* Unknown message |
| 1227 | */ |
| 1228 | { |
| @@ -1292,10 +1316,11 @@ | |
| 1316 | #define SYNC_PUSH 0x0001 |
| 1317 | #define SYNC_PULL 0x0002 |
| 1318 | #define SYNC_CLONE 0x0004 |
| 1319 | #define SYNC_PRIVATE 0x0008 |
| 1320 | #define SYNC_VERBOSE 0x0010 |
| 1321 | #define SYNC_RESYNC 0x0020 |
| 1322 | #endif |
| 1323 | |
| 1324 | /* |
| 1325 | ** Sync to the host identified in g.urlName and g.urlPath. This |
| 1326 | ** routine is called by the client. |
| @@ -1380,15 +1405,20 @@ | |
| 1405 | zOpType = "Clone"; |
| 1406 | }else if( syncFlags & SYNC_PULL ){ |
| 1407 | blob_appendf(&send, "pull %s %s\n", zSCode, zPCode); |
| 1408 | nCardSent++; |
| 1409 | zOpType = (syncFlags & SYNC_PUSH)?"Sync":"Pull"; |
| 1410 | if( (syncFlags & SYNC_RESYNC)!=0 && nCycle<2 ){ |
| 1411 | blob_appendf(&send, "pragma send-catalog\n"); |
| 1412 | nCardSent++; |
| 1413 | } |
| 1414 | } |
| 1415 | if( syncFlags & SYNC_PUSH ){ |
| 1416 | blob_appendf(&send, "push %s %s\n", zSCode, zPCode); |
| 1417 | nCardSent++; |
| 1418 | if( (syncFlags & SYNC_PULL)==0 ) zOpType = "Push"; |
| 1419 | if( (syncFlags & SYNC_RESYNC)!=0 ) xfer.resync = 0x7fffffff; |
| 1420 | } |
| 1421 | manifest_crosslink_begin(); |
| 1422 | transport_global_startup(); |
| 1423 | if( syncFlags & SYNC_VERBOSE ){ |
| 1424 | fossil_print(zLabelFormat, "", "Bytes", "Cards", "Artifacts", "Deltas"); |
| 1425 |