Fossil SCM

In the sync reply, the server should omit igot cards for artifacts that are known to already exist on the client.

drh 2020-04-12 19:12 trunk
Commit 3e2a9bc37335447c17b96125e85e342ca2c1e1e646b2d7a7b7e96a88ba4e7ee8
1 file changed +21 -3
+21 -3
--- src/xfer.c
+++ src/xfer.c
@@ -956,30 +956,48 @@
956956
}
957957
958958
/*
959959
** Send an igot message for every entry in unclustered table.
960960
** 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.
961972
*/
962973
static int send_unclustered(Xfer *pXfer){
963974
Stmt q;
964975
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
+ }
965982
if( pXfer->resync ){
966983
db_prepare(&q,
967984
"SELECT uuid, rid FROM blob"
968985
" WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
969986
" 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"
971988
" AND blob.rid<=%d"
972989
" ORDER BY blob.rid DESC",
973
- pXfer->resync
990
+ zExtra /*safe-for-%s*/, pXfer->resync
974991
);
975992
}else{
976993
db_prepare(&q,
977994
"SELECT uuid FROM unclustered JOIN blob USING(rid) /*scan*/"
978995
" WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
979996
" 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*/
981999
);
9821000
}
9831001
while( db_step(&q)==SQLITE_ROW ){
9841002
blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0));
9851003
cnt++;
9861004
--- 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

Keyboard Shortcuts

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