Fossil SCM
Improvements to comments in the sync logic. No changes to code.
Commit
18262347369e11f3a419c005c4420c95230d1fb0c2c9855576f9f6462c7bc29b
Parent
20a40056f1c58a3…
1 file changed
+47
-37
+47
-37
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -1209,11 +1209,11 @@ | ||
| 1209 | 1209 | xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken)); |
| 1210 | 1210 | |
| 1211 | 1211 | /* file HASH SIZE \n CONTENT |
| 1212 | 1212 | ** file HASH DELTASRC SIZE \n CONTENT |
| 1213 | 1213 | ** |
| 1214 | - ** Accept a file from the client. | |
| 1214 | + ** Server accepts a file from the client. | |
| 1215 | 1215 | */ |
| 1216 | 1216 | if( blob_eq(&xfer.aToken[0], "file") ){ |
| 1217 | 1217 | if( !isPush ){ |
| 1218 | 1218 | cgi_reset_content(); |
| 1219 | 1219 | @ error not\sauthorized\sto\swrite |
| @@ -1230,11 +1230,11 @@ | ||
| 1230 | 1230 | }else |
| 1231 | 1231 | |
| 1232 | 1232 | /* cfile HASH USIZE CSIZE \n CONTENT |
| 1233 | 1233 | ** cfile HASH DELTASRC USIZE CSIZE \n CONTENT |
| 1234 | 1234 | ** |
| 1235 | - ** Accept a file from the client. | |
| 1235 | + ** Server accepts a compressed file from the client. | |
| 1236 | 1236 | */ |
| 1237 | 1237 | if( blob_eq(&xfer.aToken[0], "cfile") ){ |
| 1238 | 1238 | if( !isPush ){ |
| 1239 | 1239 | cgi_reset_content(); |
| 1240 | 1240 | @ error not\sauthorized\sto\swrite |
| @@ -1250,11 +1250,11 @@ | ||
| 1250 | 1250 | } |
| 1251 | 1251 | }else |
| 1252 | 1252 | |
| 1253 | 1253 | /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT |
| 1254 | 1254 | ** |
| 1255 | - ** Accept an unversioned file from the client. | |
| 1255 | + ** Server accepts an unversioned file from the client. | |
| 1256 | 1256 | */ |
| 1257 | 1257 | if( blob_eq(&xfer.aToken[0], "uvfile") ){ |
| 1258 | 1258 | xfer_accept_unversioned_file(&xfer, g.perm.WrUnver); |
| 1259 | 1259 | if( blob_size(&xfer.err) ){ |
| 1260 | 1260 | cgi_reset_content(); |
| @@ -1264,11 +1264,11 @@ | ||
| 1264 | 1264 | } |
| 1265 | 1265 | }else |
| 1266 | 1266 | |
| 1267 | 1267 | /* gimme HASH |
| 1268 | 1268 | ** |
| 1269 | - ** Client is requesting a file. Send it. | |
| 1269 | + ** Client is requesting a file from the server. Send it. | |
| 1270 | 1270 | */ |
| 1271 | 1271 | if( blob_eq(&xfer.aToken[0], "gimme") |
| 1272 | 1272 | && xfer.nToken==2 |
| 1273 | 1273 | && blob_is_hname(&xfer.aToken[1]) |
| 1274 | 1274 | ){ |
| @@ -1281,11 +1281,11 @@ | ||
| 1281 | 1281 | } |
| 1282 | 1282 | }else |
| 1283 | 1283 | |
| 1284 | 1284 | /* uvgimme NAME |
| 1285 | 1285 | ** |
| 1286 | - ** Client is requesting an unversioned file. Send it. | |
| 1286 | + ** Client is requesting an unversioned file from the server. Send it. | |
| 1287 | 1287 | */ |
| 1288 | 1288 | if( blob_eq(&xfer.aToken[0], "uvgimme") |
| 1289 | 1289 | && xfer.nToken==2 |
| 1290 | 1290 | && blob_is_filename(&xfer.aToken[1]) |
| 1291 | 1291 | ){ |
| @@ -1408,11 +1408,12 @@ | ||
| 1408 | 1408 | @ push %s(db_get("server-code", "x")) %s(db_get("project-code", "x")) |
| 1409 | 1409 | }else |
| 1410 | 1410 | |
| 1411 | 1411 | /* login USER NONCE SIGNATURE |
| 1412 | 1412 | ** |
| 1413 | - ** Check for a valid login. This has to happen before anything else. | |
| 1413 | + ** The client has sent login credentials to the server. | |
| 1414 | + ** Validate the login. This has to happen before anything else. | |
| 1414 | 1415 | ** The client can send multiple logins. Permissions are cumulative. |
| 1415 | 1416 | */ |
| 1416 | 1417 | if( blob_eq(&xfer.aToken[0], "login") |
| 1417 | 1418 | && xfer.nToken==4 |
| 1418 | 1419 | ){ |
| @@ -1430,11 +1431,11 @@ | ||
| 1430 | 1431 | } |
| 1431 | 1432 | }else |
| 1432 | 1433 | |
| 1433 | 1434 | /* reqconfig NAME |
| 1434 | 1435 | ** |
| 1435 | - ** Request a configuration value | |
| 1436 | + ** Client is requesting a configuration value from the server | |
| 1436 | 1437 | */ |
| 1437 | 1438 | if( blob_eq(&xfer.aToken[0], "reqconfig") |
| 1438 | 1439 | && xfer.nToken==2 |
| 1439 | 1440 | ){ |
| 1440 | 1441 | if( g.perm.Read ){ |
| @@ -1449,12 +1450,12 @@ | ||
| 1449 | 1450 | } |
| 1450 | 1451 | }else |
| 1451 | 1452 | |
| 1452 | 1453 | /* config NAME SIZE \n CONTENT |
| 1453 | 1454 | ** |
| 1454 | - ** Receive a configuration value from the client. This is only | |
| 1455 | - ** permitted for high-privilege users. | |
| 1455 | + ** Client has sent a configuration value to the server. | |
| 1456 | + ** This is only permitted for high-privilege users. | |
| 1456 | 1457 | */ |
| 1457 | 1458 | if( blob_eq(&xfer.aToken[0],"config") && xfer.nToken==3 |
| 1458 | 1459 | && blob_is_int(&xfer.aToken[2], &size) ){ |
| 1459 | 1460 | const char *zName = blob_str(&xfer.aToken[1]); |
| 1460 | 1461 | Blob content; |
| @@ -1494,11 +1495,11 @@ | ||
| 1494 | 1495 | }else |
| 1495 | 1496 | |
| 1496 | 1497 | |
| 1497 | 1498 | /* private |
| 1498 | 1499 | ** |
| 1499 | - ** This card indicates that the next "file" or "cfile" will contain | |
| 1500 | + ** The client card indicates that the next "file" or "cfile" will contain | |
| 1500 | 1501 | ** private content. |
| 1501 | 1502 | */ |
| 1502 | 1503 | if( blob_eq(&xfer.aToken[0], "private") ){ |
| 1503 | 1504 | if( !g.perm.Private ){ |
| 1504 | 1505 | server_private_xfer_not_authorized(); |
| @@ -1515,10 +1516,12 @@ | ||
| 1515 | 1516 | ** ignored. |
| 1516 | 1517 | */ |
| 1517 | 1518 | if( blob_eq(&xfer.aToken[0], "pragma") && xfer.nToken>=2 ){ |
| 1518 | 1519 | |
| 1519 | 1520 | /* pragma send-private |
| 1521 | + ** | |
| 1522 | + ** The client is requesting private artifacts. | |
| 1520 | 1523 | ** |
| 1521 | 1524 | ** If the user has the "x" privilege (which must be set explicitly - |
| 1522 | 1525 | ** it is not automatic with "a" or "s") then this pragma causes |
| 1523 | 1526 | ** private information to be pulled in addition to public records. |
| 1524 | 1527 | */ |
| @@ -1531,19 +1534,22 @@ | ||
| 1531 | 1534 | } |
| 1532 | 1535 | } |
| 1533 | 1536 | |
| 1534 | 1537 | /* pragma send-catalog |
| 1535 | 1538 | ** |
| 1536 | - ** Send igot cards for all known artifacts. | |
| 1539 | + ** The client wants to see igot cards for all known artifacts. | |
| 1540 | + ** This is used as part of "sync --verily" to help ensure that | |
| 1541 | + ** no artifacts have been missed on prior syncs. | |
| 1537 | 1542 | */ |
| 1538 | 1543 | if( blob_eq(&xfer.aToken[1], "send-catalog") ){ |
| 1539 | 1544 | xfer.resync = 0x7fffffff; |
| 1540 | 1545 | } |
| 1541 | 1546 | |
| 1542 | 1547 | /* pragma client-version VERSION |
| 1543 | 1548 | ** |
| 1544 | - ** Let the server know what version of Fossil is running on the client. | |
| 1549 | + ** The client announces to the server what version of Fossil it | |
| 1550 | + ** is running. | |
| 1545 | 1551 | */ |
| 1546 | 1552 | if( xfer.nToken>=3 && blob_eq(&xfer.aToken[1], "client-version") ){ |
| 1547 | 1553 | xfer.clientVersion = atoi(blob_str(&xfer.aToken[2])); |
| 1548 | 1554 | } |
| 1549 | 1555 | |
| @@ -1570,11 +1576,11 @@ | ||
| 1570 | 1576 | |
| 1571 | 1577 | /* pragma ci-lock CHECKIN-HASH CLIENT-ID |
| 1572 | 1578 | ** |
| 1573 | 1579 | ** The client wants to make non-branch commit against the check-in |
| 1574 | 1580 | ** identified by CHECKIN-HASH. The server will remember this and |
| 1575 | - ** subsequent ci-lock request from different clients will generate | |
| 1581 | + ** subsequent ci-lock requests from different clients will generate | |
| 1576 | 1582 | ** a ci-lock-fail pragma in the reply. |
| 1577 | 1583 | */ |
| 1578 | 1584 | if( blob_eq(&xfer.aToken[1], "ci-lock") |
| 1579 | 1585 | && xfer.nToken==4 |
| 1580 | 1586 | && blob_is_hname(&xfer.aToken[2]) |
| @@ -1876,11 +1882,12 @@ | ||
| 1876 | 1882 | " SELECT name, 0 FROM unversioned WHERE hash IS NOT NULL;" |
| 1877 | 1883 | ); |
| 1878 | 1884 | } |
| 1879 | 1885 | |
| 1880 | 1886 | /* |
| 1881 | - ** Always begin with a clone, pull, or push message | |
| 1887 | + ** The request from the client always begin with a clone, pull, | |
| 1888 | + ** or push message. | |
| 1882 | 1889 | */ |
| 1883 | 1890 | blob_appendf(&send, "pragma client-version %d\n", RELEASE_VERSION_NUMBER); |
| 1884 | 1891 | if( syncFlags & SYNC_CLONE ){ |
| 1885 | 1892 | blob_appendf(&send, "clone 3 %d\n", cloneSeqno); |
| 1886 | 1893 | syncFlags &= ~(SYNC_PUSH|SYNC_PULL); |
| @@ -1918,20 +1925,19 @@ | ||
| 1918 | 1925 | "CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);" |
| 1919 | 1926 | ); |
| 1920 | 1927 | manifest_crosslink_begin(); |
| 1921 | 1928 | |
| 1922 | 1929 | |
| 1923 | - /* Send back the most recently received cookie. Let the server | |
| 1924 | - ** figure out if this is a cookie that it cares about. | |
| 1930 | + /* Client sends the most recently received cookie back to the server. | |
| 1931 | + ** Let the server figure out if this is a cookie that it cares about. | |
| 1925 | 1932 | */ |
| 1926 | 1933 | zCookie = db_get("cookie", 0); |
| 1927 | 1934 | if( zCookie ){ |
| 1928 | 1935 | blob_appendf(&send, "cookie %s\n", zCookie); |
| 1929 | 1936 | } |
| 1930 | 1937 | |
| 1931 | - /* Generate gimme cards for phantoms and leaf cards | |
| 1932 | - ** for all leaves. | |
| 1938 | + /* Client sends gimme cards for phantoms | |
| 1933 | 1939 | */ |
| 1934 | 1940 | if( (syncFlags & SYNC_PULL)!=0 |
| 1935 | 1941 | || ((syncFlags & SYNC_CLONE)!=0 && cloneSeqno==1) |
| 1936 | 1942 | ){ |
| 1937 | 1943 | request_phantoms(&xfer, mxPhantomReq); |
| @@ -1940,11 +1946,11 @@ | ||
| 1940 | 1946 | send_unsent(&xfer); |
| 1941 | 1947 | nCardSent += send_unclustered(&xfer); |
| 1942 | 1948 | if( syncFlags & SYNC_PRIVATE ) send_private(&xfer); |
| 1943 | 1949 | } |
| 1944 | 1950 | |
| 1945 | - /* Send configuration parameter requests. On a clone, delay sending | |
| 1951 | + /* Client sends configuration parameter requests. On a clone, delay sending | |
| 1946 | 1952 | ** this until the second cycle since the login card might fail on |
| 1947 | 1953 | ** the first cycle. |
| 1948 | 1954 | */ |
| 1949 | 1955 | if( configRcvMask && ((syncFlags & SYNC_CLONE)==0 || nCycle>0) ){ |
| 1950 | 1956 | const char *zName; |
| @@ -1957,13 +1963,13 @@ | ||
| 1957 | 1963 | } |
| 1958 | 1964 | origConfigRcvMask = configRcvMask; |
| 1959 | 1965 | configRcvMask = 0; |
| 1960 | 1966 | } |
| 1961 | 1967 | |
| 1962 | - /* Send a request to sync unversioned files. On a clone, delay sending | |
| 1963 | - ** this until the second cycle since the login card might fail on | |
| 1964 | - ** the first cycle. | |
| 1968 | + /* Client sends a request to sync unversioned files. | |
| 1969 | + ** On a clone, delay sending this until the second cycle since | |
| 1970 | + ** the login card might fail on the first cycle. | |
| 1965 | 1971 | */ |
| 1966 | 1972 | if( (syncFlags & SYNC_UNVERSIONED)!=0 |
| 1967 | 1973 | && ((syncFlags & SYNC_CLONE)==0 || nCycle>0) |
| 1968 | 1974 | && !uvHashSent |
| 1969 | 1975 | ){ |
| @@ -1970,11 +1976,12 @@ | ||
| 1970 | 1976 | blob_appendf(&send, "pragma uv-hash %s\n", unversioned_content_hash(0)); |
| 1971 | 1977 | nCardSent++; |
| 1972 | 1978 | uvHashSent = 1; |
| 1973 | 1979 | } |
| 1974 | 1980 | |
| 1975 | - /* Send configuration parameters being pushed */ | |
| 1981 | + /* On a "fossil config push", the client send configuration parameters | |
| 1982 | + ** being pushed up to the server */ | |
| 1976 | 1983 | if( configSendMask ){ |
| 1977 | 1984 | if( zOpType==0 ) zOpType = "Push"; |
| 1978 | 1985 | nCardSent += configure_send_group(xfer.pOut, configSendMask, 0); |
| 1979 | 1986 | configSendMask = 0; |
| 1980 | 1987 | } |
| @@ -2030,11 +2037,11 @@ | ||
| 2030 | 2037 | zCkinLock = 0; |
| 2031 | 2038 | }else if( zClientId ){ |
| 2032 | 2039 | blob_appendf(&send, "pragma ci-unlock %s\n", zClientId); |
| 2033 | 2040 | } |
| 2034 | 2041 | |
| 2035 | - /* Append randomness to the end of the message. This makes all | |
| 2042 | + /* Append randomness to the end of the uplink message. This makes all | |
| 2036 | 2043 | ** messages unique so that that the login-card nonce will always |
| 2037 | 2044 | ** be unique. |
| 2038 | 2045 | */ |
| 2039 | 2046 | zRandomness = db_text(0, "SELECT hex(randomblob(20))"); |
| 2040 | 2047 | blob_appendf(&send, "# %s\n", zRandomness); |
| @@ -2132,30 +2139,30 @@ | ||
| 2132 | 2139 | } |
| 2133 | 2140 | |
| 2134 | 2141 | /* file HASH SIZE \n CONTENT |
| 2135 | 2142 | ** file HASH DELTASRC SIZE \n CONTENT |
| 2136 | 2143 | ** |
| 2137 | - ** Receive a file transmitted from the server. | |
| 2144 | + ** Client receives a file transmitted from the server. | |
| 2138 | 2145 | */ |
| 2139 | 2146 | if( blob_eq(&xfer.aToken[0],"file") ){ |
| 2140 | 2147 | xfer_accept_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0); |
| 2141 | 2148 | nArtifactRcvd++; |
| 2142 | 2149 | }else |
| 2143 | 2150 | |
| 2144 | 2151 | /* cfile HASH USIZE CSIZE \n CONTENT |
| 2145 | 2152 | ** cfile HASH DELTASRC USIZE CSIZE \n CONTENT |
| 2146 | 2153 | ** |
| 2147 | - ** Receive a compressed file transmitted from the server. | |
| 2154 | + ** Client receives a compressed file transmitted from the server. | |
| 2148 | 2155 | */ |
| 2149 | 2156 | if( blob_eq(&xfer.aToken[0],"cfile") ){ |
| 2150 | 2157 | xfer_accept_compressed_file(&xfer, 0, 0); |
| 2151 | 2158 | nArtifactRcvd++; |
| 2152 | 2159 | }else |
| 2153 | 2160 | |
| 2154 | 2161 | /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT |
| 2155 | 2162 | ** |
| 2156 | - ** Accept an unversioned file from the server. | |
| 2163 | + ** Client accepts an unversioned file from the server. | |
| 2157 | 2164 | */ |
| 2158 | 2165 | if( blob_eq(&xfer.aToken[0], "uvfile") ){ |
| 2159 | 2166 | xfer_accept_unversioned_file(&xfer, 1); |
| 2160 | 2167 | nArtifactRcvd++; |
| 2161 | 2168 | nUvFileRcvd++; |
| @@ -2165,13 +2172,14 @@ | ||
| 2165 | 2172 | } |
| 2166 | 2173 | }else |
| 2167 | 2174 | |
| 2168 | 2175 | /* gimme HASH |
| 2169 | 2176 | ** |
| 2170 | - ** Server is requesting a file. If the file is a manifest, assume | |
| 2171 | - ** that the server will also want to know all of the content files | |
| 2172 | - ** associated with the manifest and send those too. | |
| 2177 | + ** Client receives an artifact request from the server. | |
| 2178 | + ** If the file is a manifest, assume that the server will also want | |
| 2179 | + ** to know all of the content artifacts associated with the manifest | |
| 2180 | + ** and send those too. | |
| 2173 | 2181 | */ |
| 2174 | 2182 | if( blob_eq(&xfer.aToken[0], "gimme") |
| 2175 | 2183 | && xfer.nToken==2 |
| 2176 | 2184 | && blob_is_hname(&xfer.aToken[1]) |
| 2177 | 2185 | ){ |
| @@ -2284,11 +2292,11 @@ | ||
| 2284 | 2292 | }else |
| 2285 | 2293 | |
| 2286 | 2294 | /* push SERVERCODE PRODUCTCODE |
| 2287 | 2295 | ** |
| 2288 | 2296 | ** Should only happen in response to a clone. This message tells |
| 2289 | - ** the client what product to use for the new database. | |
| 2297 | + ** the client what product code to use for the new database. | |
| 2290 | 2298 | */ |
| 2291 | 2299 | if( blob_eq(&xfer.aToken[0],"push") |
| 2292 | 2300 | && xfer.nToken==3 |
| 2293 | 2301 | && (syncFlags & SYNC_CLONE)!=0 |
| 2294 | 2302 | && blob_is_hname(&xfer.aToken[2]) |
| @@ -2301,11 +2309,11 @@ | ||
| 2301 | 2309 | nCardSent++; |
| 2302 | 2310 | }else |
| 2303 | 2311 | |
| 2304 | 2312 | /* config NAME SIZE \n CONTENT |
| 2305 | 2313 | ** |
| 2306 | - ** Receive a configuration value from the server. | |
| 2314 | + ** Client receive a configuration value from the server. | |
| 2307 | 2315 | ** |
| 2308 | 2316 | ** The received configuration setting is silently ignored if it was |
| 2309 | 2317 | ** not requested by a prior "reqconfig" sent from client to server. |
| 2310 | 2318 | */ |
| 2311 | 2319 | if( blob_eq(&xfer.aToken[0],"config") && xfer.nToken==3 |
| @@ -2323,11 +2331,11 @@ | ||
| 2323 | 2331 | }else |
| 2324 | 2332 | |
| 2325 | 2333 | |
| 2326 | 2334 | /* cookie TEXT |
| 2327 | 2335 | ** |
| 2328 | - ** The server might include a cookie in its reply. The client | |
| 2336 | + ** The client reserves a cookie from the server. The client | |
| 2329 | 2337 | ** should remember this cookie and send it back to the server |
| 2330 | 2338 | ** in its next query. |
| 2331 | 2339 | ** |
| 2332 | 2340 | ** Each cookie received overwrites the prior cookie from the |
| 2333 | 2341 | ** same server. |
| @@ -2337,12 +2345,12 @@ | ||
| 2337 | 2345 | }else |
| 2338 | 2346 | |
| 2339 | 2347 | |
| 2340 | 2348 | /* private |
| 2341 | 2349 | ** |
| 2342 | - ** This card indicates that the next "file" or "cfile" will contain | |
| 2343 | - ** private content. | |
| 2350 | + ** The server tells the client that the next "file" or "cfile" will | |
| 2351 | + ** contain private content. | |
| 2344 | 2352 | */ |
| 2345 | 2353 | if( blob_eq(&xfer.aToken[0], "private") ){ |
| 2346 | 2354 | xfer.nextIsPrivate = 1; |
| 2347 | 2355 | }else |
| 2348 | 2356 | |
| @@ -2358,11 +2366,12 @@ | ||
| 2358 | 2366 | blob_is_int(&xfer.aToken[1], &cloneSeqno); |
| 2359 | 2367 | }else |
| 2360 | 2368 | |
| 2361 | 2369 | /* message MESSAGE |
| 2362 | 2370 | ** |
| 2363 | - ** Print a message. Similar to "error" but does not stop processing. | |
| 2371 | + ** A message is received from the server. Print it. | |
| 2372 | + ** Similar to "error" but does not stop processing. | |
| 2364 | 2373 | ** |
| 2365 | 2374 | ** If the "login failed" message is seen, clear the sync password prior |
| 2366 | 2375 | ** to the next cycle. |
| 2367 | 2376 | */ |
| 2368 | 2377 | if( blob_eq(&xfer.aToken[0],"message") && xfer.nToken==2 ){ |
| @@ -2427,11 +2436,12 @@ | ||
| 2427 | 2436 | } |
| 2428 | 2437 | }else |
| 2429 | 2438 | |
| 2430 | 2439 | /* error MESSAGE |
| 2431 | 2440 | ** |
| 2432 | - ** Report an error and abandon the sync session. | |
| 2441 | + ** The server is reporting an error. The client will abandon | |
| 2442 | + ** the sync session. | |
| 2433 | 2443 | ** |
| 2434 | 2444 | ** Except, when cloning we will sometimes get an error on the |
| 2435 | 2445 | ** first message exchange because the project-code is unknown |
| 2436 | 2446 | ** and so the login card on the request was invalid. The project-code |
| 2437 | 2447 | ** is returned in the reply before the error card, so second and |
| 2438 | 2448 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1209,11 +1209,11 @@ | |
| 1209 | xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken)); |
| 1210 | |
| 1211 | /* file HASH SIZE \n CONTENT |
| 1212 | ** file HASH DELTASRC SIZE \n CONTENT |
| 1213 | ** |
| 1214 | ** Accept a file from the client. |
| 1215 | */ |
| 1216 | if( blob_eq(&xfer.aToken[0], "file") ){ |
| 1217 | if( !isPush ){ |
| 1218 | cgi_reset_content(); |
| 1219 | @ error not\sauthorized\sto\swrite |
| @@ -1230,11 +1230,11 @@ | |
| 1230 | }else |
| 1231 | |
| 1232 | /* cfile HASH USIZE CSIZE \n CONTENT |
| 1233 | ** cfile HASH DELTASRC USIZE CSIZE \n CONTENT |
| 1234 | ** |
| 1235 | ** Accept a file from the client. |
| 1236 | */ |
| 1237 | if( blob_eq(&xfer.aToken[0], "cfile") ){ |
| 1238 | if( !isPush ){ |
| 1239 | cgi_reset_content(); |
| 1240 | @ error not\sauthorized\sto\swrite |
| @@ -1250,11 +1250,11 @@ | |
| 1250 | } |
| 1251 | }else |
| 1252 | |
| 1253 | /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT |
| 1254 | ** |
| 1255 | ** Accept an unversioned file from the client. |
| 1256 | */ |
| 1257 | if( blob_eq(&xfer.aToken[0], "uvfile") ){ |
| 1258 | xfer_accept_unversioned_file(&xfer, g.perm.WrUnver); |
| 1259 | if( blob_size(&xfer.err) ){ |
| 1260 | cgi_reset_content(); |
| @@ -1264,11 +1264,11 @@ | |
| 1264 | } |
| 1265 | }else |
| 1266 | |
| 1267 | /* gimme HASH |
| 1268 | ** |
| 1269 | ** Client is requesting a file. Send it. |
| 1270 | */ |
| 1271 | if( blob_eq(&xfer.aToken[0], "gimme") |
| 1272 | && xfer.nToken==2 |
| 1273 | && blob_is_hname(&xfer.aToken[1]) |
| 1274 | ){ |
| @@ -1281,11 +1281,11 @@ | |
| 1281 | } |
| 1282 | }else |
| 1283 | |
| 1284 | /* uvgimme NAME |
| 1285 | ** |
| 1286 | ** Client is requesting an unversioned file. Send it. |
| 1287 | */ |
| 1288 | if( blob_eq(&xfer.aToken[0], "uvgimme") |
| 1289 | && xfer.nToken==2 |
| 1290 | && blob_is_filename(&xfer.aToken[1]) |
| 1291 | ){ |
| @@ -1408,11 +1408,12 @@ | |
| 1408 | @ push %s(db_get("server-code", "x")) %s(db_get("project-code", "x")) |
| 1409 | }else |
| 1410 | |
| 1411 | /* login USER NONCE SIGNATURE |
| 1412 | ** |
| 1413 | ** Check for a valid login. This has to happen before anything else. |
| 1414 | ** The client can send multiple logins. Permissions are cumulative. |
| 1415 | */ |
| 1416 | if( blob_eq(&xfer.aToken[0], "login") |
| 1417 | && xfer.nToken==4 |
| 1418 | ){ |
| @@ -1430,11 +1431,11 @@ | |
| 1430 | } |
| 1431 | }else |
| 1432 | |
| 1433 | /* reqconfig NAME |
| 1434 | ** |
| 1435 | ** Request a configuration value |
| 1436 | */ |
| 1437 | if( blob_eq(&xfer.aToken[0], "reqconfig") |
| 1438 | && xfer.nToken==2 |
| 1439 | ){ |
| 1440 | if( g.perm.Read ){ |
| @@ -1449,12 +1450,12 @@ | |
| 1449 | } |
| 1450 | }else |
| 1451 | |
| 1452 | /* config NAME SIZE \n CONTENT |
| 1453 | ** |
| 1454 | ** Receive a configuration value from the client. This is only |
| 1455 | ** permitted for high-privilege users. |
| 1456 | */ |
| 1457 | if( blob_eq(&xfer.aToken[0],"config") && xfer.nToken==3 |
| 1458 | && blob_is_int(&xfer.aToken[2], &size) ){ |
| 1459 | const char *zName = blob_str(&xfer.aToken[1]); |
| 1460 | Blob content; |
| @@ -1494,11 +1495,11 @@ | |
| 1494 | }else |
| 1495 | |
| 1496 | |
| 1497 | /* private |
| 1498 | ** |
| 1499 | ** This card indicates that the next "file" or "cfile" will contain |
| 1500 | ** private content. |
| 1501 | */ |
| 1502 | if( blob_eq(&xfer.aToken[0], "private") ){ |
| 1503 | if( !g.perm.Private ){ |
| 1504 | server_private_xfer_not_authorized(); |
| @@ -1515,10 +1516,12 @@ | |
| 1515 | ** ignored. |
| 1516 | */ |
| 1517 | if( blob_eq(&xfer.aToken[0], "pragma") && xfer.nToken>=2 ){ |
| 1518 | |
| 1519 | /* pragma send-private |
| 1520 | ** |
| 1521 | ** If the user has the "x" privilege (which must be set explicitly - |
| 1522 | ** it is not automatic with "a" or "s") then this pragma causes |
| 1523 | ** private information to be pulled in addition to public records. |
| 1524 | */ |
| @@ -1531,19 +1534,22 @@ | |
| 1531 | } |
| 1532 | } |
| 1533 | |
| 1534 | /* pragma send-catalog |
| 1535 | ** |
| 1536 | ** Send igot cards for all known artifacts. |
| 1537 | */ |
| 1538 | if( blob_eq(&xfer.aToken[1], "send-catalog") ){ |
| 1539 | xfer.resync = 0x7fffffff; |
| 1540 | } |
| 1541 | |
| 1542 | /* pragma client-version VERSION |
| 1543 | ** |
| 1544 | ** Let the server know what version of Fossil is running on the client. |
| 1545 | */ |
| 1546 | if( xfer.nToken>=3 && blob_eq(&xfer.aToken[1], "client-version") ){ |
| 1547 | xfer.clientVersion = atoi(blob_str(&xfer.aToken[2])); |
| 1548 | } |
| 1549 | |
| @@ -1570,11 +1576,11 @@ | |
| 1570 | |
| 1571 | /* pragma ci-lock CHECKIN-HASH CLIENT-ID |
| 1572 | ** |
| 1573 | ** The client wants to make non-branch commit against the check-in |
| 1574 | ** identified by CHECKIN-HASH. The server will remember this and |
| 1575 | ** subsequent ci-lock request from different clients will generate |
| 1576 | ** a ci-lock-fail pragma in the reply. |
| 1577 | */ |
| 1578 | if( blob_eq(&xfer.aToken[1], "ci-lock") |
| 1579 | && xfer.nToken==4 |
| 1580 | && blob_is_hname(&xfer.aToken[2]) |
| @@ -1876,11 +1882,12 @@ | |
| 1876 | " SELECT name, 0 FROM unversioned WHERE hash IS NOT NULL;" |
| 1877 | ); |
| 1878 | } |
| 1879 | |
| 1880 | /* |
| 1881 | ** Always begin with a clone, pull, or push message |
| 1882 | */ |
| 1883 | blob_appendf(&send, "pragma client-version %d\n", RELEASE_VERSION_NUMBER); |
| 1884 | if( syncFlags & SYNC_CLONE ){ |
| 1885 | blob_appendf(&send, "clone 3 %d\n", cloneSeqno); |
| 1886 | syncFlags &= ~(SYNC_PUSH|SYNC_PULL); |
| @@ -1918,20 +1925,19 @@ | |
| 1918 | "CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);" |
| 1919 | ); |
| 1920 | manifest_crosslink_begin(); |
| 1921 | |
| 1922 | |
| 1923 | /* Send back the most recently received cookie. Let the server |
| 1924 | ** figure out if this is a cookie that it cares about. |
| 1925 | */ |
| 1926 | zCookie = db_get("cookie", 0); |
| 1927 | if( zCookie ){ |
| 1928 | blob_appendf(&send, "cookie %s\n", zCookie); |
| 1929 | } |
| 1930 | |
| 1931 | /* Generate gimme cards for phantoms and leaf cards |
| 1932 | ** for all leaves. |
| 1933 | */ |
| 1934 | if( (syncFlags & SYNC_PULL)!=0 |
| 1935 | || ((syncFlags & SYNC_CLONE)!=0 && cloneSeqno==1) |
| 1936 | ){ |
| 1937 | request_phantoms(&xfer, mxPhantomReq); |
| @@ -1940,11 +1946,11 @@ | |
| 1940 | send_unsent(&xfer); |
| 1941 | nCardSent += send_unclustered(&xfer); |
| 1942 | if( syncFlags & SYNC_PRIVATE ) send_private(&xfer); |
| 1943 | } |
| 1944 | |
| 1945 | /* Send configuration parameter requests. On a clone, delay sending |
| 1946 | ** this until the second cycle since the login card might fail on |
| 1947 | ** the first cycle. |
| 1948 | */ |
| 1949 | if( configRcvMask && ((syncFlags & SYNC_CLONE)==0 || nCycle>0) ){ |
| 1950 | const char *zName; |
| @@ -1957,13 +1963,13 @@ | |
| 1957 | } |
| 1958 | origConfigRcvMask = configRcvMask; |
| 1959 | configRcvMask = 0; |
| 1960 | } |
| 1961 | |
| 1962 | /* Send a request to sync unversioned files. On a clone, delay sending |
| 1963 | ** this until the second cycle since the login card might fail on |
| 1964 | ** the first cycle. |
| 1965 | */ |
| 1966 | if( (syncFlags & SYNC_UNVERSIONED)!=0 |
| 1967 | && ((syncFlags & SYNC_CLONE)==0 || nCycle>0) |
| 1968 | && !uvHashSent |
| 1969 | ){ |
| @@ -1970,11 +1976,12 @@ | |
| 1970 | blob_appendf(&send, "pragma uv-hash %s\n", unversioned_content_hash(0)); |
| 1971 | nCardSent++; |
| 1972 | uvHashSent = 1; |
| 1973 | } |
| 1974 | |
| 1975 | /* Send configuration parameters being pushed */ |
| 1976 | if( configSendMask ){ |
| 1977 | if( zOpType==0 ) zOpType = "Push"; |
| 1978 | nCardSent += configure_send_group(xfer.pOut, configSendMask, 0); |
| 1979 | configSendMask = 0; |
| 1980 | } |
| @@ -2030,11 +2037,11 @@ | |
| 2030 | zCkinLock = 0; |
| 2031 | }else if( zClientId ){ |
| 2032 | blob_appendf(&send, "pragma ci-unlock %s\n", zClientId); |
| 2033 | } |
| 2034 | |
| 2035 | /* Append randomness to the end of the message. This makes all |
| 2036 | ** messages unique so that that the login-card nonce will always |
| 2037 | ** be unique. |
| 2038 | */ |
| 2039 | zRandomness = db_text(0, "SELECT hex(randomblob(20))"); |
| 2040 | blob_appendf(&send, "# %s\n", zRandomness); |
| @@ -2132,30 +2139,30 @@ | |
| 2132 | } |
| 2133 | |
| 2134 | /* file HASH SIZE \n CONTENT |
| 2135 | ** file HASH DELTASRC SIZE \n CONTENT |
| 2136 | ** |
| 2137 | ** Receive a file transmitted from the server. |
| 2138 | */ |
| 2139 | if( blob_eq(&xfer.aToken[0],"file") ){ |
| 2140 | xfer_accept_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0); |
| 2141 | nArtifactRcvd++; |
| 2142 | }else |
| 2143 | |
| 2144 | /* cfile HASH USIZE CSIZE \n CONTENT |
| 2145 | ** cfile HASH DELTASRC USIZE CSIZE \n CONTENT |
| 2146 | ** |
| 2147 | ** Receive a compressed file transmitted from the server. |
| 2148 | */ |
| 2149 | if( blob_eq(&xfer.aToken[0],"cfile") ){ |
| 2150 | xfer_accept_compressed_file(&xfer, 0, 0); |
| 2151 | nArtifactRcvd++; |
| 2152 | }else |
| 2153 | |
| 2154 | /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT |
| 2155 | ** |
| 2156 | ** Accept an unversioned file from the server. |
| 2157 | */ |
| 2158 | if( blob_eq(&xfer.aToken[0], "uvfile") ){ |
| 2159 | xfer_accept_unversioned_file(&xfer, 1); |
| 2160 | nArtifactRcvd++; |
| 2161 | nUvFileRcvd++; |
| @@ -2165,13 +2172,14 @@ | |
| 2165 | } |
| 2166 | }else |
| 2167 | |
| 2168 | /* gimme HASH |
| 2169 | ** |
| 2170 | ** Server is requesting a file. If the file is a manifest, assume |
| 2171 | ** that the server will also want to know all of the content files |
| 2172 | ** associated with the manifest and send those too. |
| 2173 | */ |
| 2174 | if( blob_eq(&xfer.aToken[0], "gimme") |
| 2175 | && xfer.nToken==2 |
| 2176 | && blob_is_hname(&xfer.aToken[1]) |
| 2177 | ){ |
| @@ -2284,11 +2292,11 @@ | |
| 2284 | }else |
| 2285 | |
| 2286 | /* push SERVERCODE PRODUCTCODE |
| 2287 | ** |
| 2288 | ** Should only happen in response to a clone. This message tells |
| 2289 | ** the client what product to use for the new database. |
| 2290 | */ |
| 2291 | if( blob_eq(&xfer.aToken[0],"push") |
| 2292 | && xfer.nToken==3 |
| 2293 | && (syncFlags & SYNC_CLONE)!=0 |
| 2294 | && blob_is_hname(&xfer.aToken[2]) |
| @@ -2301,11 +2309,11 @@ | |
| 2301 | nCardSent++; |
| 2302 | }else |
| 2303 | |
| 2304 | /* config NAME SIZE \n CONTENT |
| 2305 | ** |
| 2306 | ** Receive a configuration value from the server. |
| 2307 | ** |
| 2308 | ** The received configuration setting is silently ignored if it was |
| 2309 | ** not requested by a prior "reqconfig" sent from client to server. |
| 2310 | */ |
| 2311 | if( blob_eq(&xfer.aToken[0],"config") && xfer.nToken==3 |
| @@ -2323,11 +2331,11 @@ | |
| 2323 | }else |
| 2324 | |
| 2325 | |
| 2326 | /* cookie TEXT |
| 2327 | ** |
| 2328 | ** The server might include a cookie in its reply. The client |
| 2329 | ** should remember this cookie and send it back to the server |
| 2330 | ** in its next query. |
| 2331 | ** |
| 2332 | ** Each cookie received overwrites the prior cookie from the |
| 2333 | ** same server. |
| @@ -2337,12 +2345,12 @@ | |
| 2337 | }else |
| 2338 | |
| 2339 | |
| 2340 | /* private |
| 2341 | ** |
| 2342 | ** This card indicates that the next "file" or "cfile" will contain |
| 2343 | ** private content. |
| 2344 | */ |
| 2345 | if( blob_eq(&xfer.aToken[0], "private") ){ |
| 2346 | xfer.nextIsPrivate = 1; |
| 2347 | }else |
| 2348 | |
| @@ -2358,11 +2366,12 @@ | |
| 2358 | blob_is_int(&xfer.aToken[1], &cloneSeqno); |
| 2359 | }else |
| 2360 | |
| 2361 | /* message MESSAGE |
| 2362 | ** |
| 2363 | ** Print a message. Similar to "error" but does not stop processing. |
| 2364 | ** |
| 2365 | ** If the "login failed" message is seen, clear the sync password prior |
| 2366 | ** to the next cycle. |
| 2367 | */ |
| 2368 | if( blob_eq(&xfer.aToken[0],"message") && xfer.nToken==2 ){ |
| @@ -2427,11 +2436,12 @@ | |
| 2427 | } |
| 2428 | }else |
| 2429 | |
| 2430 | /* error MESSAGE |
| 2431 | ** |
| 2432 | ** Report an error and abandon the sync session. |
| 2433 | ** |
| 2434 | ** Except, when cloning we will sometimes get an error on the |
| 2435 | ** first message exchange because the project-code is unknown |
| 2436 | ** and so the login card on the request was invalid. The project-code |
| 2437 | ** is returned in the reply before the error card, so second and |
| 2438 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1209,11 +1209,11 @@ | |
| 1209 | xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken)); |
| 1210 | |
| 1211 | /* file HASH SIZE \n CONTENT |
| 1212 | ** file HASH DELTASRC SIZE \n CONTENT |
| 1213 | ** |
| 1214 | ** Server accepts a file from the client. |
| 1215 | */ |
| 1216 | if( blob_eq(&xfer.aToken[0], "file") ){ |
| 1217 | if( !isPush ){ |
| 1218 | cgi_reset_content(); |
| 1219 | @ error not\sauthorized\sto\swrite |
| @@ -1230,11 +1230,11 @@ | |
| 1230 | }else |
| 1231 | |
| 1232 | /* cfile HASH USIZE CSIZE \n CONTENT |
| 1233 | ** cfile HASH DELTASRC USIZE CSIZE \n CONTENT |
| 1234 | ** |
| 1235 | ** Server accepts a compressed file from the client. |
| 1236 | */ |
| 1237 | if( blob_eq(&xfer.aToken[0], "cfile") ){ |
| 1238 | if( !isPush ){ |
| 1239 | cgi_reset_content(); |
| 1240 | @ error not\sauthorized\sto\swrite |
| @@ -1250,11 +1250,11 @@ | |
| 1250 | } |
| 1251 | }else |
| 1252 | |
| 1253 | /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT |
| 1254 | ** |
| 1255 | ** Server accepts an unversioned file from the client. |
| 1256 | */ |
| 1257 | if( blob_eq(&xfer.aToken[0], "uvfile") ){ |
| 1258 | xfer_accept_unversioned_file(&xfer, g.perm.WrUnver); |
| 1259 | if( blob_size(&xfer.err) ){ |
| 1260 | cgi_reset_content(); |
| @@ -1264,11 +1264,11 @@ | |
| 1264 | } |
| 1265 | }else |
| 1266 | |
| 1267 | /* gimme HASH |
| 1268 | ** |
| 1269 | ** Client is requesting a file from the server. Send it. |
| 1270 | */ |
| 1271 | if( blob_eq(&xfer.aToken[0], "gimme") |
| 1272 | && xfer.nToken==2 |
| 1273 | && blob_is_hname(&xfer.aToken[1]) |
| 1274 | ){ |
| @@ -1281,11 +1281,11 @@ | |
| 1281 | } |
| 1282 | }else |
| 1283 | |
| 1284 | /* uvgimme NAME |
| 1285 | ** |
| 1286 | ** Client is requesting an unversioned file from the server. Send it. |
| 1287 | */ |
| 1288 | if( blob_eq(&xfer.aToken[0], "uvgimme") |
| 1289 | && xfer.nToken==2 |
| 1290 | && blob_is_filename(&xfer.aToken[1]) |
| 1291 | ){ |
| @@ -1408,11 +1408,12 @@ | |
| 1408 | @ push %s(db_get("server-code", "x")) %s(db_get("project-code", "x")) |
| 1409 | }else |
| 1410 | |
| 1411 | /* login USER NONCE SIGNATURE |
| 1412 | ** |
| 1413 | ** The client has sent login credentials to the server. |
| 1414 | ** Validate the login. This has to happen before anything else. |
| 1415 | ** The client can send multiple logins. Permissions are cumulative. |
| 1416 | */ |
| 1417 | if( blob_eq(&xfer.aToken[0], "login") |
| 1418 | && xfer.nToken==4 |
| 1419 | ){ |
| @@ -1430,11 +1431,11 @@ | |
| 1431 | } |
| 1432 | }else |
| 1433 | |
| 1434 | /* reqconfig NAME |
| 1435 | ** |
| 1436 | ** Client is requesting a configuration value from the server |
| 1437 | */ |
| 1438 | if( blob_eq(&xfer.aToken[0], "reqconfig") |
| 1439 | && xfer.nToken==2 |
| 1440 | ){ |
| 1441 | if( g.perm.Read ){ |
| @@ -1449,12 +1450,12 @@ | |
| 1450 | } |
| 1451 | }else |
| 1452 | |
| 1453 | /* config NAME SIZE \n CONTENT |
| 1454 | ** |
| 1455 | ** Client has sent a configuration value to the server. |
| 1456 | ** This is only permitted for high-privilege users. |
| 1457 | */ |
| 1458 | if( blob_eq(&xfer.aToken[0],"config") && xfer.nToken==3 |
| 1459 | && blob_is_int(&xfer.aToken[2], &size) ){ |
| 1460 | const char *zName = blob_str(&xfer.aToken[1]); |
| 1461 | Blob content; |
| @@ -1494,11 +1495,11 @@ | |
| 1495 | }else |
| 1496 | |
| 1497 | |
| 1498 | /* private |
| 1499 | ** |
| 1500 | ** The client card indicates that the next "file" or "cfile" will contain |
| 1501 | ** private content. |
| 1502 | */ |
| 1503 | if( blob_eq(&xfer.aToken[0], "private") ){ |
| 1504 | if( !g.perm.Private ){ |
| 1505 | server_private_xfer_not_authorized(); |
| @@ -1515,10 +1516,12 @@ | |
| 1516 | ** ignored. |
| 1517 | */ |
| 1518 | if( blob_eq(&xfer.aToken[0], "pragma") && xfer.nToken>=2 ){ |
| 1519 | |
| 1520 | /* pragma send-private |
| 1521 | ** |
| 1522 | ** The client is requesting private artifacts. |
| 1523 | ** |
| 1524 | ** If the user has the "x" privilege (which must be set explicitly - |
| 1525 | ** it is not automatic with "a" or "s") then this pragma causes |
| 1526 | ** private information to be pulled in addition to public records. |
| 1527 | */ |
| @@ -1531,19 +1534,22 @@ | |
| 1534 | } |
| 1535 | } |
| 1536 | |
| 1537 | /* pragma send-catalog |
| 1538 | ** |
| 1539 | ** The client wants to see igot cards for all known artifacts. |
| 1540 | ** This is used as part of "sync --verily" to help ensure that |
| 1541 | ** no artifacts have been missed on prior syncs. |
| 1542 | */ |
| 1543 | if( blob_eq(&xfer.aToken[1], "send-catalog") ){ |
| 1544 | xfer.resync = 0x7fffffff; |
| 1545 | } |
| 1546 | |
| 1547 | /* pragma client-version VERSION |
| 1548 | ** |
| 1549 | ** The client announces to the server what version of Fossil it |
| 1550 | ** is running. |
| 1551 | */ |
| 1552 | if( xfer.nToken>=3 && blob_eq(&xfer.aToken[1], "client-version") ){ |
| 1553 | xfer.clientVersion = atoi(blob_str(&xfer.aToken[2])); |
| 1554 | } |
| 1555 | |
| @@ -1570,11 +1576,11 @@ | |
| 1576 | |
| 1577 | /* pragma ci-lock CHECKIN-HASH CLIENT-ID |
| 1578 | ** |
| 1579 | ** The client wants to make non-branch commit against the check-in |
| 1580 | ** identified by CHECKIN-HASH. The server will remember this and |
| 1581 | ** subsequent ci-lock requests from different clients will generate |
| 1582 | ** a ci-lock-fail pragma in the reply. |
| 1583 | */ |
| 1584 | if( blob_eq(&xfer.aToken[1], "ci-lock") |
| 1585 | && xfer.nToken==4 |
| 1586 | && blob_is_hname(&xfer.aToken[2]) |
| @@ -1876,11 +1882,12 @@ | |
| 1882 | " SELECT name, 0 FROM unversioned WHERE hash IS NOT NULL;" |
| 1883 | ); |
| 1884 | } |
| 1885 | |
| 1886 | /* |
| 1887 | ** The request from the client always begin with a clone, pull, |
| 1888 | ** or push message. |
| 1889 | */ |
| 1890 | blob_appendf(&send, "pragma client-version %d\n", RELEASE_VERSION_NUMBER); |
| 1891 | if( syncFlags & SYNC_CLONE ){ |
| 1892 | blob_appendf(&send, "clone 3 %d\n", cloneSeqno); |
| 1893 | syncFlags &= ~(SYNC_PUSH|SYNC_PULL); |
| @@ -1918,20 +1925,19 @@ | |
| 1925 | "CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);" |
| 1926 | ); |
| 1927 | manifest_crosslink_begin(); |
| 1928 | |
| 1929 | |
| 1930 | /* Client sends the most recently received cookie back to the server. |
| 1931 | ** Let the server figure out if this is a cookie that it cares about. |
| 1932 | */ |
| 1933 | zCookie = db_get("cookie", 0); |
| 1934 | if( zCookie ){ |
| 1935 | blob_appendf(&send, "cookie %s\n", zCookie); |
| 1936 | } |
| 1937 | |
| 1938 | /* Client sends gimme cards for phantoms |
| 1939 | */ |
| 1940 | if( (syncFlags & SYNC_PULL)!=0 |
| 1941 | || ((syncFlags & SYNC_CLONE)!=0 && cloneSeqno==1) |
| 1942 | ){ |
| 1943 | request_phantoms(&xfer, mxPhantomReq); |
| @@ -1940,11 +1946,11 @@ | |
| 1946 | send_unsent(&xfer); |
| 1947 | nCardSent += send_unclustered(&xfer); |
| 1948 | if( syncFlags & SYNC_PRIVATE ) send_private(&xfer); |
| 1949 | } |
| 1950 | |
| 1951 | /* Client sends configuration parameter requests. On a clone, delay sending |
| 1952 | ** this until the second cycle since the login card might fail on |
| 1953 | ** the first cycle. |
| 1954 | */ |
| 1955 | if( configRcvMask && ((syncFlags & SYNC_CLONE)==0 || nCycle>0) ){ |
| 1956 | const char *zName; |
| @@ -1957,13 +1963,13 @@ | |
| 1963 | } |
| 1964 | origConfigRcvMask = configRcvMask; |
| 1965 | configRcvMask = 0; |
| 1966 | } |
| 1967 | |
| 1968 | /* Client sends a request to sync unversioned files. |
| 1969 | ** On a clone, delay sending this until the second cycle since |
| 1970 | ** the login card might fail on the first cycle. |
| 1971 | */ |
| 1972 | if( (syncFlags & SYNC_UNVERSIONED)!=0 |
| 1973 | && ((syncFlags & SYNC_CLONE)==0 || nCycle>0) |
| 1974 | && !uvHashSent |
| 1975 | ){ |
| @@ -1970,11 +1976,12 @@ | |
| 1976 | blob_appendf(&send, "pragma uv-hash %s\n", unversioned_content_hash(0)); |
| 1977 | nCardSent++; |
| 1978 | uvHashSent = 1; |
| 1979 | } |
| 1980 | |
| 1981 | /* On a "fossil config push", the client send configuration parameters |
| 1982 | ** being pushed up to the server */ |
| 1983 | if( configSendMask ){ |
| 1984 | if( zOpType==0 ) zOpType = "Push"; |
| 1985 | nCardSent += configure_send_group(xfer.pOut, configSendMask, 0); |
| 1986 | configSendMask = 0; |
| 1987 | } |
| @@ -2030,11 +2037,11 @@ | |
| 2037 | zCkinLock = 0; |
| 2038 | }else if( zClientId ){ |
| 2039 | blob_appendf(&send, "pragma ci-unlock %s\n", zClientId); |
| 2040 | } |
| 2041 | |
| 2042 | /* Append randomness to the end of the uplink message. This makes all |
| 2043 | ** messages unique so that that the login-card nonce will always |
| 2044 | ** be unique. |
| 2045 | */ |
| 2046 | zRandomness = db_text(0, "SELECT hex(randomblob(20))"); |
| 2047 | blob_appendf(&send, "# %s\n", zRandomness); |
| @@ -2132,30 +2139,30 @@ | |
| 2139 | } |
| 2140 | |
| 2141 | /* file HASH SIZE \n CONTENT |
| 2142 | ** file HASH DELTASRC SIZE \n CONTENT |
| 2143 | ** |
| 2144 | ** Client receives a file transmitted from the server. |
| 2145 | */ |
| 2146 | if( blob_eq(&xfer.aToken[0],"file") ){ |
| 2147 | xfer_accept_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0); |
| 2148 | nArtifactRcvd++; |
| 2149 | }else |
| 2150 | |
| 2151 | /* cfile HASH USIZE CSIZE \n CONTENT |
| 2152 | ** cfile HASH DELTASRC USIZE CSIZE \n CONTENT |
| 2153 | ** |
| 2154 | ** Client receives a compressed file transmitted from the server. |
| 2155 | */ |
| 2156 | if( blob_eq(&xfer.aToken[0],"cfile") ){ |
| 2157 | xfer_accept_compressed_file(&xfer, 0, 0); |
| 2158 | nArtifactRcvd++; |
| 2159 | }else |
| 2160 | |
| 2161 | /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT |
| 2162 | ** |
| 2163 | ** Client accepts an unversioned file from the server. |
| 2164 | */ |
| 2165 | if( blob_eq(&xfer.aToken[0], "uvfile") ){ |
| 2166 | xfer_accept_unversioned_file(&xfer, 1); |
| 2167 | nArtifactRcvd++; |
| 2168 | nUvFileRcvd++; |
| @@ -2165,13 +2172,14 @@ | |
| 2172 | } |
| 2173 | }else |
| 2174 | |
| 2175 | /* gimme HASH |
| 2176 | ** |
| 2177 | ** Client receives an artifact request from the server. |
| 2178 | ** If the file is a manifest, assume that the server will also want |
| 2179 | ** to know all of the content artifacts associated with the manifest |
| 2180 | ** and send those too. |
| 2181 | */ |
| 2182 | if( blob_eq(&xfer.aToken[0], "gimme") |
| 2183 | && xfer.nToken==2 |
| 2184 | && blob_is_hname(&xfer.aToken[1]) |
| 2185 | ){ |
| @@ -2284,11 +2292,11 @@ | |
| 2292 | }else |
| 2293 | |
| 2294 | /* push SERVERCODE PRODUCTCODE |
| 2295 | ** |
| 2296 | ** Should only happen in response to a clone. This message tells |
| 2297 | ** the client what product code to use for the new database. |
| 2298 | */ |
| 2299 | if( blob_eq(&xfer.aToken[0],"push") |
| 2300 | && xfer.nToken==3 |
| 2301 | && (syncFlags & SYNC_CLONE)!=0 |
| 2302 | && blob_is_hname(&xfer.aToken[2]) |
| @@ -2301,11 +2309,11 @@ | |
| 2309 | nCardSent++; |
| 2310 | }else |
| 2311 | |
| 2312 | /* config NAME SIZE \n CONTENT |
| 2313 | ** |
| 2314 | ** Client receive a configuration value from the server. |
| 2315 | ** |
| 2316 | ** The received configuration setting is silently ignored if it was |
| 2317 | ** not requested by a prior "reqconfig" sent from client to server. |
| 2318 | */ |
| 2319 | if( blob_eq(&xfer.aToken[0],"config") && xfer.nToken==3 |
| @@ -2323,11 +2331,11 @@ | |
| 2331 | }else |
| 2332 | |
| 2333 | |
| 2334 | /* cookie TEXT |
| 2335 | ** |
| 2336 | ** The client reserves a cookie from the server. The client |
| 2337 | ** should remember this cookie and send it back to the server |
| 2338 | ** in its next query. |
| 2339 | ** |
| 2340 | ** Each cookie received overwrites the prior cookie from the |
| 2341 | ** same server. |
| @@ -2337,12 +2345,12 @@ | |
| 2345 | }else |
| 2346 | |
| 2347 | |
| 2348 | /* private |
| 2349 | ** |
| 2350 | ** The server tells the client that the next "file" or "cfile" will |
| 2351 | ** contain private content. |
| 2352 | */ |
| 2353 | if( blob_eq(&xfer.aToken[0], "private") ){ |
| 2354 | xfer.nextIsPrivate = 1; |
| 2355 | }else |
| 2356 | |
| @@ -2358,11 +2366,12 @@ | |
| 2366 | blob_is_int(&xfer.aToken[1], &cloneSeqno); |
| 2367 | }else |
| 2368 | |
| 2369 | /* message MESSAGE |
| 2370 | ** |
| 2371 | ** A message is received from the server. Print it. |
| 2372 | ** Similar to "error" but does not stop processing. |
| 2373 | ** |
| 2374 | ** If the "login failed" message is seen, clear the sync password prior |
| 2375 | ** to the next cycle. |
| 2376 | */ |
| 2377 | if( blob_eq(&xfer.aToken[0],"message") && xfer.nToken==2 ){ |
| @@ -2427,11 +2436,12 @@ | |
| 2436 | } |
| 2437 | }else |
| 2438 | |
| 2439 | /* error MESSAGE |
| 2440 | ** |
| 2441 | ** The server is reporting an error. The client will abandon |
| 2442 | ** the sync session. |
| 2443 | ** |
| 2444 | ** Except, when cloning we will sometimes get an error on the |
| 2445 | ** first message exchange because the project-code is unknown |
| 2446 | ** and so the login card on the request was invalid. The project-code |
| 2447 | ** is returned in the reply before the error card, so second and |
| 2448 |