Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | 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. |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
ebcce3ccddf2c404a609cbf23f7d9622 |
| User & Date: | drh 2021-12-21 15:18:36.277 |
Context
|
2021-12-21
| ||
| 18:22 | For "fossil git export", add the comment line at the end of automatically generated "manifest" files so that they do not appear to be valid Fossil artifacts. check-in: 4ff45df429 user: drh tags: trunk | |
| 15:18 | 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. check-in: ebcce3ccdd user: drh tags: trunk | |
| 14:04 | For sync, the client should only send "pragma client-url" if not doing a cross-project import. check-in: b330ce6cfb user: drh tags: trunk | |
Changes
Changes to src/export.c.
| ︙ | ︙ | |||
1715 1716 1717 1718 1719 1720 1721 |
zPushCmd = mprintf("git push --mirror %$", zPushUrl);
rc = fossil_system(zPushCmd);
if( rc ){
fossil_fatal("cannot push content using: %s", zPushCmd);
}else if( db_is_writeable("repository") ){
db_unprotect(PROTECT_CONFIG);
db_multi_exec("REPLACE INTO config(name,value,mtime)"
| | | 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 |
zPushCmd = mprintf("git push --mirror %$", zPushUrl);
rc = fossil_system(zPushCmd);
if( rc ){
fossil_fatal("cannot push content using: %s", zPushCmd);
}else if( db_is_writeable("repository") ){
db_unprotect(PROTECT_CONFIG);
db_multi_exec("REPLACE INTO config(name,value,mtime)"
"VALUES('gitpush:%q','{}',now())", zPushUrl);
db_protect_pop();
}
fossil_free(zPushCmd);
}
}
/*
|
| ︙ | ︙ |
Changes to src/xfer.c.
| ︙ | ︙ | |||
1152 1153 1154 1155 1156 1157 1158 1159 |
int xfer_run_common_script(void){
return xfer_run_script(xfer_common_code(), 0, 0);
}
/*
** This routine makes a "syncwith:URL" entry in the CONFIG table to
** indicate that a sync is occuring with zUrl.
*/
| > > | > | | 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 |
int xfer_run_common_script(void){
return xfer_run_script(xfer_common_code(), 0, 0);
}
/*
** This routine makes a "syncwith:URL" entry in the CONFIG table to
** indicate that a sync is occuring with zUrl.
**
** Add a "syncfrom:URL" entry instead of "syncwith:URL" if bSyncFrom is true.
*/
static void xfer_syncwith(const char *zUrl, int bSyncFrom){
UrlData x;
memset(&x, 0, sizeof(x));
url_parse_local(zUrl, URL_OMIT_USER, &x);
if( x.protocol && strncmp(x.protocol,"http",4)==0
&& x.name && sqlite3_strlike("%localhost%", x.name, 0)!=0
){
db_unprotect(PROTECT_CONFIG);
db_multi_exec("REPLACE INTO config(name,value,mtime)"
"VALUES('sync%q:%q','{}',now())",
bSyncFrom ? "from" : "with", x.canonical);
db_protect_pop();
}
url_unparse(&x);
}
/*
** If this variable is set, disable login checks. Used for debugging
|
| ︙ | ︙ | |||
1735 1736 1737 1738 1739 1740 1741 |
** their relationship could, in theory, be inverted by having the
** server call the client at URL.
*/
if( blob_eq(&xfer.aToken[1], "client-url")
&& xfer.nToken==3
&& g.perm.Write
){
| | | 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 |
** their relationship could, in theory, be inverted by having the
** server call the client at URL.
*/
if( blob_eq(&xfer.aToken[1], "client-url")
&& xfer.nToken==3
&& g.perm.Write
){
xfer_syncwith(blob_str(&xfer.aToken[2]), 1);
}
}else
/* Unknown message
*/
{
|
| ︙ | ︙ | |||
2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 |
if( (syncFlags & SYNC_PULL)==0 ) zOpType = "Push";
if( (syncFlags & SYNC_RESYNC)!=0 ) xfer.resync = 0x7fffffff;
}
if( syncFlags & SYNC_VERBOSE ){
fossil_print(zLabelFormat /*works-like:"%s%s%s%s%d"*/,
"", "Bytes", "Cards", "Artifacts", "Deltas");
}
while( go ){
int newPhantom = 0;
char *zRandomness;
db_begin_transaction();
db_record_repository_filename(0);
db_multi_exec(
| > > > > > > > > > > > > > > > > | 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 |
if( (syncFlags & SYNC_PULL)==0 ) zOpType = "Push";
if( (syncFlags & SYNC_RESYNC)!=0 ) xfer.resync = 0x7fffffff;
}
if( syncFlags & SYNC_VERBOSE ){
fossil_print(zLabelFormat /*works-like:"%s%s%s%s%d"*/,
"", "Bytes", "Cards", "Artifacts", "Deltas");
}
/* Send the client-url pragma on the first cycle if the client has
** a known public url.
*/
if( zAltPCode==0 ){
const char *zSelfUrl = public_url();
if( zSelfUrl ){
blob_appendf(&send, "pragma client-url %s\n", zSelfUrl);
}
}
/* Request names of alternative repositories
*/
if( zAltPCode==0 ){
blob_appendf(&send, "pragma req-alt-repo\n");
}
while( go ){
int newPhantom = 0;
char *zRandomness;
db_begin_transaction();
db_record_repository_filename(0);
db_multi_exec(
|
| ︙ | ︙ | |||
2194 2195 2196 2197 2198 2199 2200 |
go = 2;
break;
}
/* Remember the URL of the sync target in the config file on the
** first successful round-trip */
if( nCycle==0 && db_is_writeable("repository") ){
| | < < < < < < < < < < | 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 |
go = 2;
break;
}
/* Remember the URL of the sync target in the config file on the
** first successful round-trip */
if( nCycle==0 && db_is_writeable("repository") ){
xfer_syncwith(g.url.canonical, 0);
}
/* Output current stats */
if( syncFlags & SYNC_VERBOSE ){
fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Sent:",
blob_size(&send), nCardSent+xfer.nGimmeSent+xfer.nIGotSent,
xfer.nFileSent, xfer.nDeltaSent);
|
| ︙ | ︙ |