Fossil SCM

Fix the "pragma client-url" and "pragma req-alt-repo" pragmas to that they are in fact sent on the first message. Begin using "{}" as the value for config setings such as "syncwith" so that the value can later be extended to hold JSON.

drh 2021-12-21 15:18 trunk
Commit ebcce3ccddf2c404a609cbf23f7d96220c9ee2dd0fc92abef82b5b5823c68341
2 files changed +1 -1 +23 -14
+1 -1
--- src/export.c
+++ src/export.c
@@ -1717,11 +1717,11 @@
17171717
if( rc ){
17181718
fossil_fatal("cannot push content using: %s", zPushCmd);
17191719
}else if( db_is_writeable("repository") ){
17201720
db_unprotect(PROTECT_CONFIG);
17211721
db_multi_exec("REPLACE INTO config(name,value,mtime)"
1722
- "VALUES('gitpush:%q',1,now())", zPushUrl);
1722
+ "VALUES('gitpush:%q','{}',now())", zPushUrl);
17231723
db_protect_pop();
17241724
}
17251725
fossil_free(zPushCmd);
17261726
}
17271727
}
17281728
--- src/export.c
+++ src/export.c
@@ -1717,11 +1717,11 @@
1717 if( rc ){
1718 fossil_fatal("cannot push content using: %s", zPushCmd);
1719 }else if( db_is_writeable("repository") ){
1720 db_unprotect(PROTECT_CONFIG);
1721 db_multi_exec("REPLACE INTO config(name,value,mtime)"
1722 "VALUES('gitpush:%q',1,now())", zPushUrl);
1723 db_protect_pop();
1724 }
1725 fossil_free(zPushCmd);
1726 }
1727 }
1728
--- src/export.c
+++ src/export.c
@@ -1717,11 +1717,11 @@
1717 if( rc ){
1718 fossil_fatal("cannot push content using: %s", zPushCmd);
1719 }else if( db_is_writeable("repository") ){
1720 db_unprotect(PROTECT_CONFIG);
1721 db_multi_exec("REPLACE INTO config(name,value,mtime)"
1722 "VALUES('gitpush:%q','{}',now())", zPushUrl);
1723 db_protect_pop();
1724 }
1725 fossil_free(zPushCmd);
1726 }
1727 }
1728
+23 -14
--- src/xfer.c
+++ src/xfer.c
@@ -1154,21 +1154,24 @@
11541154
}
11551155
11561156
/*
11571157
** This routine makes a "syncwith:URL" entry in the CONFIG table to
11581158
** indicate that a sync is occuring with zUrl.
1159
+**
1160
+** Add a "syncfrom:URL" entry instead of "syncwith:URL" if bSyncFrom is true.
11591161
*/
1160
-static void xfer_syncwith(const char *zUrl){
1162
+static void xfer_syncwith(const char *zUrl, int bSyncFrom){
11611163
UrlData x;
11621164
memset(&x, 0, sizeof(x));
11631165
url_parse_local(zUrl, URL_OMIT_USER, &x);
11641166
if( x.protocol && strncmp(x.protocol,"http",4)==0
11651167
&& x.name && sqlite3_strlike("%localhost%", x.name, 0)!=0
11661168
){
11671169
db_unprotect(PROTECT_CONFIG);
11681170
db_multi_exec("REPLACE INTO config(name,value,mtime)"
1169
- "VALUES('syncwith:%q',1,now())", x.canonical);
1171
+ "VALUES('sync%q:%q','{}',now())",
1172
+ bSyncFrom ? "from" : "with", x.canonical);
11701173
db_protect_pop();
11711174
}
11721175
url_unparse(&x);
11731176
}
11741177
@@ -1737,11 +1740,11 @@
17371740
*/
17381741
if( blob_eq(&xfer.aToken[1], "client-url")
17391742
&& xfer.nToken==3
17401743
&& g.perm.Write
17411744
){
1742
- xfer_syncwith(blob_str(&xfer.aToken[2]));
1745
+ xfer_syncwith(blob_str(&xfer.aToken[2]), 1);
17431746
}
17441747
17451748
}else
17461749
17471750
/* Unknown message
@@ -2038,10 +2041,26 @@
20382041
}
20392042
if( syncFlags & SYNC_VERBOSE ){
20402043
fossil_print(zLabelFormat /*works-like:"%s%s%s%s%d"*/,
20412044
"", "Bytes", "Cards", "Artifacts", "Deltas");
20422045
}
2046
+
2047
+ /* Send the client-url pragma on the first cycle if the client has
2048
+ ** a known public url.
2049
+ */
2050
+ if( zAltPCode==0 ){
2051
+ const char *zSelfUrl = public_url();
2052
+ if( zSelfUrl ){
2053
+ blob_appendf(&send, "pragma client-url %s\n", zSelfUrl);
2054
+ }
2055
+ }
2056
+
2057
+ /* Request names of alternative repositories
2058
+ */
2059
+ if( zAltPCode==0 ){
2060
+ blob_appendf(&send, "pragma req-alt-repo\n");
2061
+ }
20432062
20442063
while( go ){
20452064
int newPhantom = 0;
20462065
char *zRandomness;
20472066
db_begin_transaction();
@@ -2196,21 +2215,11 @@
21962215
}
21972216
21982217
/* Remember the URL of the sync target in the config file on the
21992218
** first successful round-trip */
22002219
if( nCycle==0 && db_is_writeable("repository") ){
2201
- xfer_syncwith(g.url.canonical);
2202
- }
2203
-
2204
- /* Send the client-url pragma on the first cycle if the client has
2205
- ** a known public url.
2206
- */
2207
- if( nCycle==0 && zAltPCode==0 ){
2208
- const char *zSelfUrl = public_url();
2209
- if( zSelfUrl ){
2210
- blob_appendf(&send, "pragma client-url %s\n", zSelfUrl);
2211
- }
2220
+ xfer_syncwith(g.url.canonical, 0);
22122221
}
22132222
22142223
/* Output current stats */
22152224
if( syncFlags & SYNC_VERBOSE ){
22162225
fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Sent:",
22172226
--- src/xfer.c
+++ src/xfer.c
@@ -1154,21 +1154,24 @@
1154 }
1155
1156 /*
1157 ** This routine makes a "syncwith:URL" entry in the CONFIG table to
1158 ** indicate that a sync is occuring with zUrl.
 
 
1159 */
1160 static void xfer_syncwith(const char *zUrl){
1161 UrlData x;
1162 memset(&x, 0, sizeof(x));
1163 url_parse_local(zUrl, URL_OMIT_USER, &x);
1164 if( x.protocol && strncmp(x.protocol,"http",4)==0
1165 && x.name && sqlite3_strlike("%localhost%", x.name, 0)!=0
1166 ){
1167 db_unprotect(PROTECT_CONFIG);
1168 db_multi_exec("REPLACE INTO config(name,value,mtime)"
1169 "VALUES('syncwith:%q',1,now())", x.canonical);
 
1170 db_protect_pop();
1171 }
1172 url_unparse(&x);
1173 }
1174
@@ -1737,11 +1740,11 @@
1737 */
1738 if( blob_eq(&xfer.aToken[1], "client-url")
1739 && xfer.nToken==3
1740 && g.perm.Write
1741 ){
1742 xfer_syncwith(blob_str(&xfer.aToken[2]));
1743 }
1744
1745 }else
1746
1747 /* Unknown message
@@ -2038,10 +2041,26 @@
2038 }
2039 if( syncFlags & SYNC_VERBOSE ){
2040 fossil_print(zLabelFormat /*works-like:"%s%s%s%s%d"*/,
2041 "", "Bytes", "Cards", "Artifacts", "Deltas");
2042 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2043
2044 while( go ){
2045 int newPhantom = 0;
2046 char *zRandomness;
2047 db_begin_transaction();
@@ -2196,21 +2215,11 @@
2196 }
2197
2198 /* Remember the URL of the sync target in the config file on the
2199 ** first successful round-trip */
2200 if( nCycle==0 && db_is_writeable("repository") ){
2201 xfer_syncwith(g.url.canonical);
2202 }
2203
2204 /* Send the client-url pragma on the first cycle if the client has
2205 ** a known public url.
2206 */
2207 if( nCycle==0 && zAltPCode==0 ){
2208 const char *zSelfUrl = public_url();
2209 if( zSelfUrl ){
2210 blob_appendf(&send, "pragma client-url %s\n", zSelfUrl);
2211 }
2212 }
2213
2214 /* Output current stats */
2215 if( syncFlags & SYNC_VERBOSE ){
2216 fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Sent:",
2217
--- src/xfer.c
+++ src/xfer.c
@@ -1154,21 +1154,24 @@
1154 }
1155
1156 /*
1157 ** This routine makes a "syncwith:URL" entry in the CONFIG table to
1158 ** indicate that a sync is occuring with zUrl.
1159 **
1160 ** Add a "syncfrom:URL" entry instead of "syncwith:URL" if bSyncFrom is true.
1161 */
1162 static void xfer_syncwith(const char *zUrl, int bSyncFrom){
1163 UrlData x;
1164 memset(&x, 0, sizeof(x));
1165 url_parse_local(zUrl, URL_OMIT_USER, &x);
1166 if( x.protocol && strncmp(x.protocol,"http",4)==0
1167 && x.name && sqlite3_strlike("%localhost%", x.name, 0)!=0
1168 ){
1169 db_unprotect(PROTECT_CONFIG);
1170 db_multi_exec("REPLACE INTO config(name,value,mtime)"
1171 "VALUES('sync%q:%q','{}',now())",
1172 bSyncFrom ? "from" : "with", x.canonical);
1173 db_protect_pop();
1174 }
1175 url_unparse(&x);
1176 }
1177
@@ -1737,11 +1740,11 @@
1740 */
1741 if( blob_eq(&xfer.aToken[1], "client-url")
1742 && xfer.nToken==3
1743 && g.perm.Write
1744 ){
1745 xfer_syncwith(blob_str(&xfer.aToken[2]), 1);
1746 }
1747
1748 }else
1749
1750 /* Unknown message
@@ -2038,10 +2041,26 @@
2041 }
2042 if( syncFlags & SYNC_VERBOSE ){
2043 fossil_print(zLabelFormat /*works-like:"%s%s%s%s%d"*/,
2044 "", "Bytes", "Cards", "Artifacts", "Deltas");
2045 }
2046
2047 /* Send the client-url pragma on the first cycle if the client has
2048 ** a known public url.
2049 */
2050 if( zAltPCode==0 ){
2051 const char *zSelfUrl = public_url();
2052 if( zSelfUrl ){
2053 blob_appendf(&send, "pragma client-url %s\n", zSelfUrl);
2054 }
2055 }
2056
2057 /* Request names of alternative repositories
2058 */
2059 if( zAltPCode==0 ){
2060 blob_appendf(&send, "pragma req-alt-repo\n");
2061 }
2062
2063 while( go ){
2064 int newPhantom = 0;
2065 char *zRandomness;
2066 db_begin_transaction();
@@ -2196,21 +2215,11 @@
2215 }
2216
2217 /* Remember the URL of the sync target in the config file on the
2218 ** first successful round-trip */
2219 if( nCycle==0 && db_is_writeable("repository") ){
2220 xfer_syncwith(g.url.canonical, 0);
 
 
 
 
 
 
 
 
 
 
2221 }
2222
2223 /* Output current stats */
2224 if( syncFlags & SYNC_VERBOSE ){
2225 fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Sent:",
2226

Keyboard Shortcuts

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