Fossil SCM
In the sync reply, the server should omit igot cards for artifacts that are known to already exist on the client.
Commit
3e2a9bc37335447c17b96125e85e342ca2c1e1e646b2d7a7b7e96a88ba4e7ee8
Parent
55f9d7b6ecfce6c…
1 file changed
+21
-3
+21
-3
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -956,30 +956,48 @@ | ||
| 956 | 956 | } |
| 957 | 957 | |
| 958 | 958 | /* |
| 959 | 959 | ** Send an igot message for every entry in unclustered table. |
| 960 | 960 | ** Return the number of cards sent. |
| 961 | +** | |
| 962 | +** Except: | |
| 963 | +** * Do not send igot cards for shunned artifacts | |
| 964 | +** * Do not send igot cards for phantoms | |
| 965 | +** * Do not send igot cards for private artifacts | |
| 966 | +** * Do not send igot cards for any artifact that is in the | |
| 967 | +** ONREMOTE table, if that table exists. | |
| 968 | +** | |
| 969 | +** If the pXfer->resync flag is set, that means we are doing a "--verily" | |
| 970 | +** sync and all artifacts that don't meet the restrictions above should | |
| 971 | +** be sent. | |
| 961 | 972 | */ |
| 962 | 973 | static int send_unclustered(Xfer *pXfer){ |
| 963 | 974 | Stmt q; |
| 964 | 975 | int cnt = 0; |
| 976 | + const char *zExtra; | |
| 977 | + if( db_table_exists("temp","onremote") ){ | |
| 978 | + zExtra = " AND NOT EXISTS(SELECT 1 FROM onremote WHERE rid=blob.rid)"; | |
| 979 | + }else{ | |
| 980 | + zExtra = ""; | |
| 981 | + } | |
| 965 | 982 | if( pXfer->resync ){ |
| 966 | 983 | db_prepare(&q, |
| 967 | 984 | "SELECT uuid, rid FROM blob" |
| 968 | 985 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" |
| 969 | 986 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)" |
| 970 | - " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)" | |
| 987 | + " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)%s" | |
| 971 | 988 | " AND blob.rid<=%d" |
| 972 | 989 | " ORDER BY blob.rid DESC", |
| 973 | - pXfer->resync | |
| 990 | + zExtra /*safe-for-%s*/, pXfer->resync | |
| 974 | 991 | ); |
| 975 | 992 | }else{ |
| 976 | 993 | db_prepare(&q, |
| 977 | 994 | "SELECT uuid FROM unclustered JOIN blob USING(rid) /*scan*/" |
| 978 | 995 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" |
| 979 | 996 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)" |
| 980 | - " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)" | |
| 997 | + " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)%s", | |
| 998 | + zExtra /*safe-for-%s*/ | |
| 981 | 999 | ); |
| 982 | 1000 | } |
| 983 | 1001 | while( db_step(&q)==SQLITE_ROW ){ |
| 984 | 1002 | blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0)); |
| 985 | 1003 | cnt++; |
| 986 | 1004 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -956,30 +956,48 @@ | |
| 956 | } |
| 957 | |
| 958 | /* |
| 959 | ** Send an igot message for every entry in unclustered table. |
| 960 | ** Return the number of cards sent. |
| 961 | */ |
| 962 | static int send_unclustered(Xfer *pXfer){ |
| 963 | Stmt q; |
| 964 | int cnt = 0; |
| 965 | if( pXfer->resync ){ |
| 966 | db_prepare(&q, |
| 967 | "SELECT uuid, rid FROM blob" |
| 968 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" |
| 969 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)" |
| 970 | " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)" |
| 971 | " AND blob.rid<=%d" |
| 972 | " ORDER BY blob.rid DESC", |
| 973 | pXfer->resync |
| 974 | ); |
| 975 | }else{ |
| 976 | db_prepare(&q, |
| 977 | "SELECT uuid FROM unclustered JOIN blob USING(rid) /*scan*/" |
| 978 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" |
| 979 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)" |
| 980 | " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)" |
| 981 | ); |
| 982 | } |
| 983 | while( db_step(&q)==SQLITE_ROW ){ |
| 984 | blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0)); |
| 985 | cnt++; |
| 986 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -956,30 +956,48 @@ | |
| 956 | } |
| 957 | |
| 958 | /* |
| 959 | ** Send an igot message for every entry in unclustered table. |
| 960 | ** Return the number of cards sent. |
| 961 | ** |
| 962 | ** Except: |
| 963 | ** * Do not send igot cards for shunned artifacts |
| 964 | ** * Do not send igot cards for phantoms |
| 965 | ** * Do not send igot cards for private artifacts |
| 966 | ** * Do not send igot cards for any artifact that is in the |
| 967 | ** ONREMOTE table, if that table exists. |
| 968 | ** |
| 969 | ** If the pXfer->resync flag is set, that means we are doing a "--verily" |
| 970 | ** sync and all artifacts that don't meet the restrictions above should |
| 971 | ** be sent. |
| 972 | */ |
| 973 | static int send_unclustered(Xfer *pXfer){ |
| 974 | Stmt q; |
| 975 | int cnt = 0; |
| 976 | const char *zExtra; |
| 977 | if( db_table_exists("temp","onremote") ){ |
| 978 | zExtra = " AND NOT EXISTS(SELECT 1 FROM onremote WHERE rid=blob.rid)"; |
| 979 | }else{ |
| 980 | zExtra = ""; |
| 981 | } |
| 982 | if( pXfer->resync ){ |
| 983 | db_prepare(&q, |
| 984 | "SELECT uuid, rid FROM blob" |
| 985 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" |
| 986 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)" |
| 987 | " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)%s" |
| 988 | " AND blob.rid<=%d" |
| 989 | " ORDER BY blob.rid DESC", |
| 990 | zExtra /*safe-for-%s*/, pXfer->resync |
| 991 | ); |
| 992 | }else{ |
| 993 | db_prepare(&q, |
| 994 | "SELECT uuid FROM unclustered JOIN blob USING(rid) /*scan*/" |
| 995 | " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)" |
| 996 | " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)" |
| 997 | " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)%s", |
| 998 | zExtra /*safe-for-%s*/ |
| 999 | ); |
| 1000 | } |
| 1001 | while( db_step(&q)==SQLITE_ROW ){ |
| 1002 | blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0)); |
| 1003 | cnt++; |
| 1004 |