Fossil SCM

Use a new pragma requested only in the first clone cycle to track the rebuilt time on the remote server to be able to error out if the rids are rebuilt before resuming a clone. This is currently just a fossilized string but it could instead by a hash of the components to make it more like a "code". Requesting the pragma only at the beginning does not account for the possibility that a rebuild will happen after the clone begins. I find that scenario highly unlikely, but grant that it might be possible.

andybradford 2023-12-02 18:30 clone-resume
Commit 7f116a437ccfd18853a9f52e8f04196eda662fb069f74ad70123d5d734bbcfd1
1 file changed +36 -3
+36 -3
--- src/xfer.c
+++ src/xfer.c
@@ -1762,10 +1762,24 @@
17621762
** The client sends this message to the server to ask the server
17631763
** to tell it about alternative repositories in the reply.
17641764
*/
17651765
if( blob_eq(&xfer.aToken[1], "req-links") ){
17661766
bSendLinks = 1;
1767
+ }else
1768
+
1769
+ /* pragma send-rebuilt
1770
+ **
1771
+ ** The client sends this message to the server to ask the server
1772
+ ** for the last time its database was rebuilt
1773
+ */
1774
+ if( blob_eq(&xfer.aToken[1], "send-rebuilt") ){
1775
+ Blob rcode;
1776
+ blob_zero(&rcode);
1777
+ blob_appendf(&rcode, "%s-%s", db_get("server-code",0),
1778
+ db_get("rebuilt",0));
1779
+ @ pragma rebuilt %F(blob_str(&rcode))
1780
+ blob_reset(&rcode);
17671781
}
17681782
17691783
}else
17701784
17711785
/* Unknown message
@@ -2114,10 +2128,14 @@
21142128
MANIFEST_NUMERIC_TIME);
21152129
if( syncFlags & SYNC_CLONE ){
21162130
#if !defined(_WIN32)
21172131
signal(SIGINT, sync_sigint_handler);
21182132
#endif
2133
+ if( nCycle<2 ){
2134
+ /* Only request this at the beginning of the clone */
2135
+ blob_appendf(&send, "pragma send-rebuilt\n");
2136
+ }
21192137
blob_appendf(&send, "clone 3 %d\n", cloneSeqno);
21202138
syncFlags &= ~(SYNC_PUSH|SYNC_PULL);
21212139
nCardSent++;
21222140
/* TBD: Request all transferable configuration values */
21232141
content_enable_dephantomize(0);
@@ -2581,13 +2599,15 @@
25812599
){
25822600
if( zPCode==0 ){
25832601
zPCode = mprintf("%b", &xfer.aToken[2]);
25842602
db_set("project-code", zPCode, 0);
25852603
}
2586
- if( zCCode==0 && blob_is_hname(&xfer.aToken[1]) ){
2587
- zCCode = mprintf("%b", &xfer.aToken[1]);
2588
- db_set("aux-clone-code", zCCode, 0);
2604
+ if( zCCode==0 ){
2605
+ if( blob_is_hname(&xfer.aToken[1]) ){
2606
+ zCCode = mprintf("%b", &xfer.aToken[1]);
2607
+ db_set("aux-clone-code", zCCode, 0);
2608
+ }
25892609
}
25902610
if( cloneSeqno>0 ) blob_appendf(&send, "clone 3 %d\n", cloneSeqno);
25912611
nCardSent++;
25922612
}else
25932613
@@ -2773,10 +2793,23 @@
27732793
);
27742794
db_protect_pop();
27752795
}
27762796
url_unparse(&x);
27772797
}
2798
+
2799
+ /* pragma rebuilt FOSSILISZESTRING
2800
+ **
2801
+ ** The server generates this message in response to a client request
2802
+ ** that is trying to resume.
2803
+ */
2804
+ else if( blob_eq(&xfer.aToken[1], "rebuilt")
2805
+ && xfer.nToken==3
2806
+ && (syncFlags & SYNC_CLONE)!=0
2807
+ ){
2808
+ zCCode = mprintf("%b", &xfer.aToken[2]);
2809
+ db_set("aux-clone-code", zCCode, 0);
2810
+ }
27782811
27792812
}else
27802813
27812814
/* error MESSAGE
27822815
**
27832816
--- src/xfer.c
+++ src/xfer.c
@@ -1762,10 +1762,24 @@
1762 ** The client sends this message to the server to ask the server
1763 ** to tell it about alternative repositories in the reply.
1764 */
1765 if( blob_eq(&xfer.aToken[1], "req-links") ){
1766 bSendLinks = 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1767 }
1768
1769 }else
1770
1771 /* Unknown message
@@ -2114,10 +2128,14 @@
2114 MANIFEST_NUMERIC_TIME);
2115 if( syncFlags & SYNC_CLONE ){
2116 #if !defined(_WIN32)
2117 signal(SIGINT, sync_sigint_handler);
2118 #endif
 
 
 
 
2119 blob_appendf(&send, "clone 3 %d\n", cloneSeqno);
2120 syncFlags &= ~(SYNC_PUSH|SYNC_PULL);
2121 nCardSent++;
2122 /* TBD: Request all transferable configuration values */
2123 content_enable_dephantomize(0);
@@ -2581,13 +2599,15 @@
2581 ){
2582 if( zPCode==0 ){
2583 zPCode = mprintf("%b", &xfer.aToken[2]);
2584 db_set("project-code", zPCode, 0);
2585 }
2586 if( zCCode==0 && blob_is_hname(&xfer.aToken[1]) ){
2587 zCCode = mprintf("%b", &xfer.aToken[1]);
2588 db_set("aux-clone-code", zCCode, 0);
 
 
2589 }
2590 if( cloneSeqno>0 ) blob_appendf(&send, "clone 3 %d\n", cloneSeqno);
2591 nCardSent++;
2592 }else
2593
@@ -2773,10 +2793,23 @@
2773 );
2774 db_protect_pop();
2775 }
2776 url_unparse(&x);
2777 }
 
 
 
 
 
 
 
 
 
 
 
 
 
2778
2779 }else
2780
2781 /* error MESSAGE
2782 **
2783
--- src/xfer.c
+++ src/xfer.c
@@ -1762,10 +1762,24 @@
1762 ** The client sends this message to the server to ask the server
1763 ** to tell it about alternative repositories in the reply.
1764 */
1765 if( blob_eq(&xfer.aToken[1], "req-links") ){
1766 bSendLinks = 1;
1767 }else
1768
1769 /* pragma send-rebuilt
1770 **
1771 ** The client sends this message to the server to ask the server
1772 ** for the last time its database was rebuilt
1773 */
1774 if( blob_eq(&xfer.aToken[1], "send-rebuilt") ){
1775 Blob rcode;
1776 blob_zero(&rcode);
1777 blob_appendf(&rcode, "%s-%s", db_get("server-code",0),
1778 db_get("rebuilt",0));
1779 @ pragma rebuilt %F(blob_str(&rcode))
1780 blob_reset(&rcode);
1781 }
1782
1783 }else
1784
1785 /* Unknown message
@@ -2114,10 +2128,14 @@
2128 MANIFEST_NUMERIC_TIME);
2129 if( syncFlags & SYNC_CLONE ){
2130 #if !defined(_WIN32)
2131 signal(SIGINT, sync_sigint_handler);
2132 #endif
2133 if( nCycle<2 ){
2134 /* Only request this at the beginning of the clone */
2135 blob_appendf(&send, "pragma send-rebuilt\n");
2136 }
2137 blob_appendf(&send, "clone 3 %d\n", cloneSeqno);
2138 syncFlags &= ~(SYNC_PUSH|SYNC_PULL);
2139 nCardSent++;
2140 /* TBD: Request all transferable configuration values */
2141 content_enable_dephantomize(0);
@@ -2581,13 +2599,15 @@
2599 ){
2600 if( zPCode==0 ){
2601 zPCode = mprintf("%b", &xfer.aToken[2]);
2602 db_set("project-code", zPCode, 0);
2603 }
2604 if( zCCode==0 ){
2605 if( blob_is_hname(&xfer.aToken[1]) ){
2606 zCCode = mprintf("%b", &xfer.aToken[1]);
2607 db_set("aux-clone-code", zCCode, 0);
2608 }
2609 }
2610 if( cloneSeqno>0 ) blob_appendf(&send, "clone 3 %d\n", cloneSeqno);
2611 nCardSent++;
2612 }else
2613
@@ -2773,10 +2793,23 @@
2793 );
2794 db_protect_pop();
2795 }
2796 url_unparse(&x);
2797 }
2798
2799 /* pragma rebuilt FOSSILISZESTRING
2800 **
2801 ** The server generates this message in response to a client request
2802 ** that is trying to resume.
2803 */
2804 else if( blob_eq(&xfer.aToken[1], "rebuilt")
2805 && xfer.nToken==3
2806 && (syncFlags & SYNC_CLONE)!=0
2807 ){
2808 zCCode = mprintf("%b", &xfer.aToken[2]);
2809 db_set("aux-clone-code", zCCode, 0);
2810 }
2811
2812 }else
2813
2814 /* error MESSAGE
2815 **
2816

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button