Fossil SCM
Correctly handle private igot cards received in the server reply.
Commit
50a7f89a77e0886fc107b984fadd6b9ceb06de0bd559b042c92907d78fd7e8f3
Parent
10c90175a702dcc…
2 files changed
+12
+7
-4
+12
| --- src/content.c | ||
| +++ src/content.c | ||
| @@ -774,10 +774,22 @@ | ||
| 774 | 774 | void content_make_public(int rid){ |
| 775 | 775 | static Stmt s1; |
| 776 | 776 | db_static_prepare(&s1, |
| 777 | 777 | "DELETE FROM private WHERE rid=:rid" |
| 778 | 778 | ); |
| 779 | + db_bind_int(&s1, ":rid", rid); | |
| 780 | + db_exec(&s1); | |
| 781 | +} | |
| 782 | + | |
| 783 | +/* | |
| 784 | +** Make sure an artifact is private | |
| 785 | +*/ | |
| 786 | +void content_make_private(int rid){ | |
| 787 | + static Stmt s1; | |
| 788 | + db_static_prepare(&s1, | |
| 789 | + "INSERT OR IGNORE INTO private(rid) VALUES(:rid)" | |
| 790 | + ); | |
| 779 | 791 | db_bind_int(&s1, ":rid", rid); |
| 780 | 792 | db_exec(&s1); |
| 781 | 793 | } |
| 782 | 794 | |
| 783 | 795 | /* |
| 784 | 796 |
| --- src/content.c | |
| +++ src/content.c | |
| @@ -774,10 +774,22 @@ | |
| 774 | void content_make_public(int rid){ |
| 775 | static Stmt s1; |
| 776 | db_static_prepare(&s1, |
| 777 | "DELETE FROM private WHERE rid=:rid" |
| 778 | ); |
| 779 | db_bind_int(&s1, ":rid", rid); |
| 780 | db_exec(&s1); |
| 781 | } |
| 782 | |
| 783 | /* |
| 784 |
| --- src/content.c | |
| +++ src/content.c | |
| @@ -774,10 +774,22 @@ | |
| 774 | void content_make_public(int rid){ |
| 775 | static Stmt s1; |
| 776 | db_static_prepare(&s1, |
| 777 | "DELETE FROM private WHERE rid=:rid" |
| 778 | ); |
| 779 | db_bind_int(&s1, ":rid", rid); |
| 780 | db_exec(&s1); |
| 781 | } |
| 782 | |
| 783 | /* |
| 784 | ** Make sure an artifact is private |
| 785 | */ |
| 786 | void content_make_private(int rid){ |
| 787 | static Stmt s1; |
| 788 | db_static_prepare(&s1, |
| 789 | "INSERT OR IGNORE INTO private(rid) VALUES(:rid)" |
| 790 | ); |
| 791 | db_bind_int(&s1, ":rid", rid); |
| 792 | db_exec(&s1); |
| 793 | } |
| 794 | |
| 795 | /* |
| 796 |
+7
-4
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -1332,11 +1332,11 @@ | ||
| 1332 | 1332 | ** artifact here on the server as a phantom, make sure that |
| 1333 | 1333 | ** phantom is marked as private so that we don't keep asking about |
| 1334 | 1334 | ** it in subsequent sync requests. */ |
| 1335 | 1335 | rid = rid_from_uuid(&xfer.aToken[1], 0, 1); |
| 1336 | 1336 | if( rid>0 ){ |
| 1337 | - db_multi_exec("INSERT OR IGNORE INTO private(rid) VALUES(%d)",rid); | |
| 1337 | + content_make_private(rid); | |
| 1338 | 1338 | } |
| 1339 | 1339 | } |
| 1340 | 1340 | if( rid ) remote_has(rid); |
| 1341 | 1341 | } |
| 1342 | 1342 | }else |
| @@ -2246,14 +2246,17 @@ | ||
| 2246 | 2246 | ){ |
| 2247 | 2247 | int rid; |
| 2248 | 2248 | int isPriv = xfer.nToken>=3 && blob_eq(&xfer.aToken[2],"1"); |
| 2249 | 2249 | rid = rid_from_uuid(&xfer.aToken[1], 0, 0); |
| 2250 | 2250 | if( rid>0 ){ |
| 2251 | - if( !isPriv ) content_make_public(rid); | |
| 2252 | - }else if( isPriv && !g.perm.Private ){ | |
| 2251 | + if( isPriv ){ | |
| 2252 | + content_make_private(rid); | |
| 2253 | + }else{ | |
| 2254 | + content_make_public(rid); | |
| 2255 | + } | |
| 2256 | + }else if( !g.perm.Private ){ | |
| 2253 | 2257 | /* ignore private files */ |
| 2254 | - db_multi_exec("INSERT OR IGNORE INTO private VALUES(%d)", rid); | |
| 2255 | 2258 | }else if( (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0 ){ |
| 2256 | 2259 | rid = content_new(blob_str(&xfer.aToken[1]), isPriv); |
| 2257 | 2260 | if( rid ) newPhantom = 1; |
| 2258 | 2261 | } |
| 2259 | 2262 | remote_has(rid); |
| 2260 | 2263 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1332,11 +1332,11 @@ | |
| 1332 | ** artifact here on the server as a phantom, make sure that |
| 1333 | ** phantom is marked as private so that we don't keep asking about |
| 1334 | ** it in subsequent sync requests. */ |
| 1335 | rid = rid_from_uuid(&xfer.aToken[1], 0, 1); |
| 1336 | if( rid>0 ){ |
| 1337 | db_multi_exec("INSERT OR IGNORE INTO private(rid) VALUES(%d)",rid); |
| 1338 | } |
| 1339 | } |
| 1340 | if( rid ) remote_has(rid); |
| 1341 | } |
| 1342 | }else |
| @@ -2246,14 +2246,17 @@ | |
| 2246 | ){ |
| 2247 | int rid; |
| 2248 | int isPriv = xfer.nToken>=3 && blob_eq(&xfer.aToken[2],"1"); |
| 2249 | rid = rid_from_uuid(&xfer.aToken[1], 0, 0); |
| 2250 | if( rid>0 ){ |
| 2251 | if( !isPriv ) content_make_public(rid); |
| 2252 | }else if( isPriv && !g.perm.Private ){ |
| 2253 | /* ignore private files */ |
| 2254 | db_multi_exec("INSERT OR IGNORE INTO private VALUES(%d)", rid); |
| 2255 | }else if( (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0 ){ |
| 2256 | rid = content_new(blob_str(&xfer.aToken[1]), isPriv); |
| 2257 | if( rid ) newPhantom = 1; |
| 2258 | } |
| 2259 | remote_has(rid); |
| 2260 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1332,11 +1332,11 @@ | |
| 1332 | ** artifact here on the server as a phantom, make sure that |
| 1333 | ** phantom is marked as private so that we don't keep asking about |
| 1334 | ** it in subsequent sync requests. */ |
| 1335 | rid = rid_from_uuid(&xfer.aToken[1], 0, 1); |
| 1336 | if( rid>0 ){ |
| 1337 | content_make_private(rid); |
| 1338 | } |
| 1339 | } |
| 1340 | if( rid ) remote_has(rid); |
| 1341 | } |
| 1342 | }else |
| @@ -2246,14 +2246,17 @@ | |
| 2246 | ){ |
| 2247 | int rid; |
| 2248 | int isPriv = xfer.nToken>=3 && blob_eq(&xfer.aToken[2],"1"); |
| 2249 | rid = rid_from_uuid(&xfer.aToken[1], 0, 0); |
| 2250 | if( rid>0 ){ |
| 2251 | if( isPriv ){ |
| 2252 | content_make_private(rid); |
| 2253 | }else{ |
| 2254 | content_make_public(rid); |
| 2255 | } |
| 2256 | }else if( !g.perm.Private ){ |
| 2257 | /* ignore private files */ |
| 2258 | }else if( (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0 ){ |
| 2259 | rid = content_new(blob_str(&xfer.aToken[1]), isPriv); |
| 2260 | if( rid ) newPhantom = 1; |
| 2261 | } |
| 2262 | remote_has(rid); |
| 2263 |