Fossil SCM
Infrastructure changes: Simplify content_put() to a single parameter. Add content_put_ex() with lots of extra parameters. Add isPrivate parameters to content_put_ex() and content_new().
Commit
1b4516168d1e979ed743d5982fb591305dde447b
Parent
691fccbaf7afee9…
13 files changed
+3
-3
+1
-1
+2
-2
+30
-6
+1
-1
+1
-1
+1
-1
+1
-1
+1
-1
+2
-2
+4
-3
+3
-3
+8
-8
+3
-3
| --- src/attach.c | ||
| +++ src/attach.c | ||
| @@ -241,11 +241,11 @@ | ||
| 241 | 241 | int rid; |
| 242 | 242 | int i, n; |
| 243 | 243 | |
| 244 | 244 | db_begin_transaction(); |
| 245 | 245 | blob_init(&content, aContent, szContent); |
| 246 | - rid = content_put(&content, 0, 0, 0); | |
| 246 | + rid = content_put(&content); | |
| 247 | 247 | zUUID = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 248 | 248 | blob_zero(&manifest); |
| 249 | 249 | for(i=n=0; zName[i]; i++){ |
| 250 | 250 | if( zName[i]=='/' || zName[i]=='\\' ) n = i; |
| 251 | 251 | } |
| @@ -262,11 +262,11 @@ | ||
| 262 | 262 | zDate = date_in_standard_format("now"); |
| 263 | 263 | blob_appendf(&manifest, "D %s\n", zDate); |
| 264 | 264 | blob_appendf(&manifest, "U %F\n", g.zLogin ? g.zLogin : "nobody"); |
| 265 | 265 | md5sum_blob(&manifest, &cksum); |
| 266 | 266 | blob_appendf(&manifest, "Z %b\n", &cksum); |
| 267 | - rid = content_put(&manifest, 0, 0, 0); | |
| 267 | + rid = content_put(&manifest); | |
| 268 | 268 | manifest_crosslink(rid, &manifest); |
| 269 | 269 | assert( blob_is_reset(&manifest) ); |
| 270 | 270 | db_end_transaction(0); |
| 271 | 271 | cgi_redirect(zFrom); |
| 272 | 272 | } |
| @@ -342,11 +342,11 @@ | ||
| 342 | 342 | zDate = date_in_standard_format("now"); |
| 343 | 343 | blob_appendf(&manifest, "D %s\n", zDate); |
| 344 | 344 | blob_appendf(&manifest, "U %F\n", g.zLogin ? g.zLogin : "nobody"); |
| 345 | 345 | md5sum_blob(&manifest, &cksum); |
| 346 | 346 | blob_appendf(&manifest, "Z %b\n", &cksum); |
| 347 | - rid = content_put(&manifest, 0, 0, 0); | |
| 347 | + rid = content_put(&manifest); | |
| 348 | 348 | manifest_crosslink(rid, &manifest); |
| 349 | 349 | db_end_transaction(0); |
| 350 | 350 | cgi_redirect(zFrom); |
| 351 | 351 | } |
| 352 | 352 | style_header("Delete Attachment"); |
| 353 | 353 |
| --- src/attach.c | |
| +++ src/attach.c | |
| @@ -241,11 +241,11 @@ | |
| 241 | int rid; |
| 242 | int i, n; |
| 243 | |
| 244 | db_begin_transaction(); |
| 245 | blob_init(&content, aContent, szContent); |
| 246 | rid = content_put(&content, 0, 0, 0); |
| 247 | zUUID = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 248 | blob_zero(&manifest); |
| 249 | for(i=n=0; zName[i]; i++){ |
| 250 | if( zName[i]=='/' || zName[i]=='\\' ) n = i; |
| 251 | } |
| @@ -262,11 +262,11 @@ | |
| 262 | zDate = date_in_standard_format("now"); |
| 263 | blob_appendf(&manifest, "D %s\n", zDate); |
| 264 | blob_appendf(&manifest, "U %F\n", g.zLogin ? g.zLogin : "nobody"); |
| 265 | md5sum_blob(&manifest, &cksum); |
| 266 | blob_appendf(&manifest, "Z %b\n", &cksum); |
| 267 | rid = content_put(&manifest, 0, 0, 0); |
| 268 | manifest_crosslink(rid, &manifest); |
| 269 | assert( blob_is_reset(&manifest) ); |
| 270 | db_end_transaction(0); |
| 271 | cgi_redirect(zFrom); |
| 272 | } |
| @@ -342,11 +342,11 @@ | |
| 342 | zDate = date_in_standard_format("now"); |
| 343 | blob_appendf(&manifest, "D %s\n", zDate); |
| 344 | blob_appendf(&manifest, "U %F\n", g.zLogin ? g.zLogin : "nobody"); |
| 345 | md5sum_blob(&manifest, &cksum); |
| 346 | blob_appendf(&manifest, "Z %b\n", &cksum); |
| 347 | rid = content_put(&manifest, 0, 0, 0); |
| 348 | manifest_crosslink(rid, &manifest); |
| 349 | db_end_transaction(0); |
| 350 | cgi_redirect(zFrom); |
| 351 | } |
| 352 | style_header("Delete Attachment"); |
| 353 |
| --- src/attach.c | |
| +++ src/attach.c | |
| @@ -241,11 +241,11 @@ | |
| 241 | int rid; |
| 242 | int i, n; |
| 243 | |
| 244 | db_begin_transaction(); |
| 245 | blob_init(&content, aContent, szContent); |
| 246 | rid = content_put(&content); |
| 247 | zUUID = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 248 | blob_zero(&manifest); |
| 249 | for(i=n=0; zName[i]; i++){ |
| 250 | if( zName[i]=='/' || zName[i]=='\\' ) n = i; |
| 251 | } |
| @@ -262,11 +262,11 @@ | |
| 262 | zDate = date_in_standard_format("now"); |
| 263 | blob_appendf(&manifest, "D %s\n", zDate); |
| 264 | blob_appendf(&manifest, "U %F\n", g.zLogin ? g.zLogin : "nobody"); |
| 265 | md5sum_blob(&manifest, &cksum); |
| 266 | blob_appendf(&manifest, "Z %b\n", &cksum); |
| 267 | rid = content_put(&manifest); |
| 268 | manifest_crosslink(rid, &manifest); |
| 269 | assert( blob_is_reset(&manifest) ); |
| 270 | db_end_transaction(0); |
| 271 | cgi_redirect(zFrom); |
| 272 | } |
| @@ -342,11 +342,11 @@ | |
| 342 | zDate = date_in_standard_format("now"); |
| 343 | blob_appendf(&manifest, "D %s\n", zDate); |
| 344 | blob_appendf(&manifest, "U %F\n", g.zLogin ? g.zLogin : "nobody"); |
| 345 | md5sum_blob(&manifest, &cksum); |
| 346 | blob_appendf(&manifest, "Z %b\n", &cksum); |
| 347 | rid = content_put(&manifest); |
| 348 | manifest_crosslink(rid, &manifest); |
| 349 | db_end_transaction(0); |
| 350 | cgi_redirect(zFrom); |
| 351 | } |
| 352 | style_header("Delete Attachment"); |
| 353 |
+1
-1
| --- src/branch.c | ||
| +++ src/branch.c | ||
| @@ -136,11 +136,11 @@ | ||
| 136 | 136 | db_end_transaction(1); |
| 137 | 137 | fossil_exit(1); |
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - brid = content_put(&branch, 0, 0, 0); | |
| 141 | + brid = content_put(&branch); | |
| 142 | 142 | if( brid==0 ){ |
| 143 | 143 | fossil_panic("trouble committing manifest: %s", g.zErrMsg); |
| 144 | 144 | } |
| 145 | 145 | db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid); |
| 146 | 146 | if( manifest_crosslink(brid, &branch)==0 ){ |
| 147 | 147 |
| --- src/branch.c | |
| +++ src/branch.c | |
| @@ -136,11 +136,11 @@ | |
| 136 | db_end_transaction(1); |
| 137 | fossil_exit(1); |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | brid = content_put(&branch, 0, 0, 0); |
| 142 | if( brid==0 ){ |
| 143 | fossil_panic("trouble committing manifest: %s", g.zErrMsg); |
| 144 | } |
| 145 | db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid); |
| 146 | if( manifest_crosslink(brid, &branch)==0 ){ |
| 147 |
| --- src/branch.c | |
| +++ src/branch.c | |
| @@ -136,11 +136,11 @@ | |
| 136 | db_end_transaction(1); |
| 137 | fossil_exit(1); |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | brid = content_put(&branch); |
| 142 | if( brid==0 ){ |
| 143 | fossil_panic("trouble committing manifest: %s", g.zErrMsg); |
| 144 | } |
| 145 | db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid); |
| 146 | if( manifest_crosslink(brid, &branch)==0 ){ |
| 147 |
+2
-2
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -994,11 +994,11 @@ | ||
| 994 | 994 | zFullname = db_column_text(&q, 1); |
| 995 | 995 | rid = db_column_int(&q, 2); |
| 996 | 996 | |
| 997 | 997 | blob_zero(&content); |
| 998 | 998 | blob_read_from_file(&content, zFullname); |
| 999 | - nrid = content_put(&content, 0, 0, 0); | |
| 999 | + nrid = content_put(&content); | |
| 1000 | 1000 | blob_reset(&content); |
| 1001 | 1001 | if( rid>0 ){ |
| 1002 | 1002 | content_deltify(rid, nrid, 0); |
| 1003 | 1003 | } |
| 1004 | 1004 | db_multi_exec("UPDATE vfile SET mrid=%d, rid=%d WHERE id=%d", nrid,nrid,id); |
| @@ -1086,11 +1086,11 @@ | ||
| 1086 | 1086 | blob_write_to_file(&manifest, zManifestFile); |
| 1087 | 1087 | blob_reset(&manifest); |
| 1088 | 1088 | blob_read_from_file(&manifest, zManifestFile); |
| 1089 | 1089 | free(zManifestFile); |
| 1090 | 1090 | } |
| 1091 | - nvid = content_put(&manifest, 0, 0, 0); | |
| 1091 | + nvid = content_put(&manifest); | |
| 1092 | 1092 | if( nvid==0 ){ |
| 1093 | 1093 | fossil_panic("trouble committing manifest: %s", g.zErrMsg); |
| 1094 | 1094 | } |
| 1095 | 1095 | db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid); |
| 1096 | 1096 | manifest_crosslink(nvid, &manifest); |
| 1097 | 1097 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -994,11 +994,11 @@ | |
| 994 | zFullname = db_column_text(&q, 1); |
| 995 | rid = db_column_int(&q, 2); |
| 996 | |
| 997 | blob_zero(&content); |
| 998 | blob_read_from_file(&content, zFullname); |
| 999 | nrid = content_put(&content, 0, 0, 0); |
| 1000 | blob_reset(&content); |
| 1001 | if( rid>0 ){ |
| 1002 | content_deltify(rid, nrid, 0); |
| 1003 | } |
| 1004 | db_multi_exec("UPDATE vfile SET mrid=%d, rid=%d WHERE id=%d", nrid,nrid,id); |
| @@ -1086,11 +1086,11 @@ | |
| 1086 | blob_write_to_file(&manifest, zManifestFile); |
| 1087 | blob_reset(&manifest); |
| 1088 | blob_read_from_file(&manifest, zManifestFile); |
| 1089 | free(zManifestFile); |
| 1090 | } |
| 1091 | nvid = content_put(&manifest, 0, 0, 0); |
| 1092 | if( nvid==0 ){ |
| 1093 | fossil_panic("trouble committing manifest: %s", g.zErrMsg); |
| 1094 | } |
| 1095 | db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid); |
| 1096 | manifest_crosslink(nvid, &manifest); |
| 1097 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -994,11 +994,11 @@ | |
| 994 | zFullname = db_column_text(&q, 1); |
| 995 | rid = db_column_int(&q, 2); |
| 996 | |
| 997 | blob_zero(&content); |
| 998 | blob_read_from_file(&content, zFullname); |
| 999 | nrid = content_put(&content); |
| 1000 | blob_reset(&content); |
| 1001 | if( rid>0 ){ |
| 1002 | content_deltify(rid, nrid, 0); |
| 1003 | } |
| 1004 | db_multi_exec("UPDATE vfile SET mrid=%d, rid=%d WHERE id=%d", nrid,nrid,id); |
| @@ -1086,11 +1086,11 @@ | |
| 1086 | blob_write_to_file(&manifest, zManifestFile); |
| 1087 | blob_reset(&manifest); |
| 1088 | blob_read_from_file(&manifest, zManifestFile); |
| 1089 | free(zManifestFile); |
| 1090 | } |
| 1091 | nvid = content_put(&manifest); |
| 1092 | if( nvid==0 ){ |
| 1093 | fossil_panic("trouble committing manifest: %s", g.zErrMsg); |
| 1094 | } |
| 1095 | db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid); |
| 1096 | manifest_crosslink(nvid, &manifest); |
| 1097 |
+30
-6
| --- src/content.c | ||
| +++ src/content.c | ||
| @@ -430,11 +430,13 @@ | ||
| 430 | 430 | /* |
| 431 | 431 | ** Write content into the database. Return the record ID. If the |
| 432 | 432 | ** content is already in the database, just return the record ID. |
| 433 | 433 | ** |
| 434 | 434 | ** If srcId is specified, then pBlob is delta content from |
| 435 | -** the srcId record. srcId might be a phantom. If nBlob>0 then the | |
| 435 | +** the srcId record. srcId might be a phantom. | |
| 436 | +** | |
| 437 | +** pBlob is normally uncompressed text. But if nBlob>0 then the | |
| 436 | 438 | ** pBlob value has already been compressed and nBlob is its uncompressed |
| 437 | 439 | ** size. If nBlob>0 then zUuid must be valid. |
| 438 | 440 | ** |
| 439 | 441 | ** zUuid is the UUID of the artifact, if it is specified. When srcId is |
| 440 | 442 | ** specified then zUuid must always be specified. If srcId is zero, |
| @@ -445,11 +447,17 @@ | ||
| 445 | 447 | ** |
| 446 | 448 | ** The original content of pBlob is not disturbed. The caller continues |
| 447 | 449 | ** to be responsible for pBlob. This routine does *not* take over |
| 448 | 450 | ** responsiblity for freeing pBlob. |
| 449 | 451 | */ |
| 450 | -int content_put(Blob *pBlob, const char *zUuid, int srcId, int nBlob){ | |
| 452 | +int content_put_ex( | |
| 453 | + Blob *pBlob, /* Content to add to the repository */ | |
| 454 | + const char *zUuid, /* SHA1 hash of reconstructed pBlob */ | |
| 455 | + int srcId, /* pBlob is a delta from this entry */ | |
| 456 | + int nBlob, /* pBlob is compressed. Original size is this */ | |
| 457 | + int isPrivate /* The content should be marked private */ | |
| 458 | +){ | |
| 451 | 459 | int size; |
| 452 | 460 | int rid; |
| 453 | 461 | Stmt s1; |
| 454 | 462 | Blob cmpr; |
| 455 | 463 | Blob hash; |
| @@ -535,11 +543,11 @@ | ||
| 535 | 543 | db_exec(&s1); |
| 536 | 544 | rid = db_last_insert_rowid(); |
| 537 | 545 | if( !pBlob ){ |
| 538 | 546 | db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid); |
| 539 | 547 | } |
| 540 | - if( g.markPrivate ){ | |
| 548 | + if( g.markPrivate || isPrivate ){ | |
| 541 | 549 | db_multi_exec("INSERT INTO private VALUES(%d)", rid); |
| 542 | 550 | markAsUnclustered = 0; |
| 543 | 551 | } |
| 544 | 552 | } |
| 545 | 553 | if( nBlob==0 ) blob_reset(&cmpr); |
| @@ -573,15 +581,31 @@ | ||
| 573 | 581 | /* Make arrangements to verify that the data can be recovered |
| 574 | 582 | ** before we commit */ |
| 575 | 583 | verify_before_commit(rid); |
| 576 | 584 | return rid; |
| 577 | 585 | } |
| 586 | + | |
| 587 | +/* | |
| 588 | +** This is the simple common case for inserting content into the | |
| 589 | +** repository. pBlob is the content to be inserted. | |
| 590 | +** | |
| 591 | +** pBlob is uncompressed and is not deltaed. It is exactly the content | |
| 592 | +** to be inserted. | |
| 593 | +** | |
| 594 | +** The original content of pBlob is not disturbed. The caller continues | |
| 595 | +** to be responsible for pBlob. This routine does *not* take over | |
| 596 | +** responsiblity for freeing pBlob. | |
| 597 | +*/ | |
| 598 | +int content_put(Blob *pBlob){ | |
| 599 | + return content_put_ex(pBlob, 0, 0, 0, 0); | |
| 600 | +} | |
| 601 | + | |
| 578 | 602 | |
| 579 | 603 | /* |
| 580 | 604 | ** Create a new phantom with the given UUID and return its artifact ID. |
| 581 | 605 | */ |
| 582 | -int content_new(const char *zUuid){ | |
| 606 | +int content_new(const char *zUuid, int isPrivate){ | |
| 583 | 607 | int rid; |
| 584 | 608 | static Stmt s1, s2, s3; |
| 585 | 609 | |
| 586 | 610 | assert( g.repositoryOpen ); |
| 587 | 611 | db_begin_transaction(); |
| @@ -599,11 +623,11 @@ | ||
| 599 | 623 | db_static_prepare(&s2, |
| 600 | 624 | "INSERT INTO phantom VALUES(:rid)" |
| 601 | 625 | ); |
| 602 | 626 | db_bind_int(&s2, ":rid", rid); |
| 603 | 627 | db_exec(&s2); |
| 604 | - if( g.markPrivate ){ | |
| 628 | + if( g.markPrivate || isPrivate ){ | |
| 605 | 629 | db_multi_exec("INSERT INTO private VALUES(%d)", rid); |
| 606 | 630 | }else{ |
| 607 | 631 | db_static_prepare(&s3, |
| 608 | 632 | "INSERT INTO unclustered VALUES(:rid)" |
| 609 | 633 | ); |
| @@ -626,11 +650,11 @@ | ||
| 626 | 650 | Blob content; |
| 627 | 651 | if( g.argc!=3 ) usage("FILENAME"); |
| 628 | 652 | db_must_be_within_tree(); |
| 629 | 653 | user_select(); |
| 630 | 654 | blob_read_from_file(&content, g.argv[2]); |
| 631 | - rid = content_put(&content, 0, 0, 0); | |
| 655 | + rid = content_put(&content); | |
| 632 | 656 | printf("inserted as record %d\n", rid); |
| 633 | 657 | } |
| 634 | 658 | |
| 635 | 659 | /* |
| 636 | 660 | ** Make sure the content at rid is the original content and is not a |
| 637 | 661 |
| --- src/content.c | |
| +++ src/content.c | |
| @@ -430,11 +430,13 @@ | |
| 430 | /* |
| 431 | ** Write content into the database. Return the record ID. If the |
| 432 | ** content is already in the database, just return the record ID. |
| 433 | ** |
| 434 | ** If srcId is specified, then pBlob is delta content from |
| 435 | ** the srcId record. srcId might be a phantom. If nBlob>0 then the |
| 436 | ** pBlob value has already been compressed and nBlob is its uncompressed |
| 437 | ** size. If nBlob>0 then zUuid must be valid. |
| 438 | ** |
| 439 | ** zUuid is the UUID of the artifact, if it is specified. When srcId is |
| 440 | ** specified then zUuid must always be specified. If srcId is zero, |
| @@ -445,11 +447,17 @@ | |
| 445 | ** |
| 446 | ** The original content of pBlob is not disturbed. The caller continues |
| 447 | ** to be responsible for pBlob. This routine does *not* take over |
| 448 | ** responsiblity for freeing pBlob. |
| 449 | */ |
| 450 | int content_put(Blob *pBlob, const char *zUuid, int srcId, int nBlob){ |
| 451 | int size; |
| 452 | int rid; |
| 453 | Stmt s1; |
| 454 | Blob cmpr; |
| 455 | Blob hash; |
| @@ -535,11 +543,11 @@ | |
| 535 | db_exec(&s1); |
| 536 | rid = db_last_insert_rowid(); |
| 537 | if( !pBlob ){ |
| 538 | db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid); |
| 539 | } |
| 540 | if( g.markPrivate ){ |
| 541 | db_multi_exec("INSERT INTO private VALUES(%d)", rid); |
| 542 | markAsUnclustered = 0; |
| 543 | } |
| 544 | } |
| 545 | if( nBlob==0 ) blob_reset(&cmpr); |
| @@ -573,15 +581,31 @@ | |
| 573 | /* Make arrangements to verify that the data can be recovered |
| 574 | ** before we commit */ |
| 575 | verify_before_commit(rid); |
| 576 | return rid; |
| 577 | } |
| 578 | |
| 579 | /* |
| 580 | ** Create a new phantom with the given UUID and return its artifact ID. |
| 581 | */ |
| 582 | int content_new(const char *zUuid){ |
| 583 | int rid; |
| 584 | static Stmt s1, s2, s3; |
| 585 | |
| 586 | assert( g.repositoryOpen ); |
| 587 | db_begin_transaction(); |
| @@ -599,11 +623,11 @@ | |
| 599 | db_static_prepare(&s2, |
| 600 | "INSERT INTO phantom VALUES(:rid)" |
| 601 | ); |
| 602 | db_bind_int(&s2, ":rid", rid); |
| 603 | db_exec(&s2); |
| 604 | if( g.markPrivate ){ |
| 605 | db_multi_exec("INSERT INTO private VALUES(%d)", rid); |
| 606 | }else{ |
| 607 | db_static_prepare(&s3, |
| 608 | "INSERT INTO unclustered VALUES(:rid)" |
| 609 | ); |
| @@ -626,11 +650,11 @@ | |
| 626 | Blob content; |
| 627 | if( g.argc!=3 ) usage("FILENAME"); |
| 628 | db_must_be_within_tree(); |
| 629 | user_select(); |
| 630 | blob_read_from_file(&content, g.argv[2]); |
| 631 | rid = content_put(&content, 0, 0, 0); |
| 632 | printf("inserted as record %d\n", rid); |
| 633 | } |
| 634 | |
| 635 | /* |
| 636 | ** Make sure the content at rid is the original content and is not a |
| 637 |
| --- src/content.c | |
| +++ src/content.c | |
| @@ -430,11 +430,13 @@ | |
| 430 | /* |
| 431 | ** Write content into the database. Return the record ID. If the |
| 432 | ** content is already in the database, just return the record ID. |
| 433 | ** |
| 434 | ** If srcId is specified, then pBlob is delta content from |
| 435 | ** the srcId record. srcId might be a phantom. |
| 436 | ** |
| 437 | ** pBlob is normally uncompressed text. But if nBlob>0 then the |
| 438 | ** pBlob value has already been compressed and nBlob is its uncompressed |
| 439 | ** size. If nBlob>0 then zUuid must be valid. |
| 440 | ** |
| 441 | ** zUuid is the UUID of the artifact, if it is specified. When srcId is |
| 442 | ** specified then zUuid must always be specified. If srcId is zero, |
| @@ -445,11 +447,17 @@ | |
| 447 | ** |
| 448 | ** The original content of pBlob is not disturbed. The caller continues |
| 449 | ** to be responsible for pBlob. This routine does *not* take over |
| 450 | ** responsiblity for freeing pBlob. |
| 451 | */ |
| 452 | int content_put_ex( |
| 453 | Blob *pBlob, /* Content to add to the repository */ |
| 454 | const char *zUuid, /* SHA1 hash of reconstructed pBlob */ |
| 455 | int srcId, /* pBlob is a delta from this entry */ |
| 456 | int nBlob, /* pBlob is compressed. Original size is this */ |
| 457 | int isPrivate /* The content should be marked private */ |
| 458 | ){ |
| 459 | int size; |
| 460 | int rid; |
| 461 | Stmt s1; |
| 462 | Blob cmpr; |
| 463 | Blob hash; |
| @@ -535,11 +543,11 @@ | |
| 543 | db_exec(&s1); |
| 544 | rid = db_last_insert_rowid(); |
| 545 | if( !pBlob ){ |
| 546 | db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid); |
| 547 | } |
| 548 | if( g.markPrivate || isPrivate ){ |
| 549 | db_multi_exec("INSERT INTO private VALUES(%d)", rid); |
| 550 | markAsUnclustered = 0; |
| 551 | } |
| 552 | } |
| 553 | if( nBlob==0 ) blob_reset(&cmpr); |
| @@ -573,15 +581,31 @@ | |
| 581 | /* Make arrangements to verify that the data can be recovered |
| 582 | ** before we commit */ |
| 583 | verify_before_commit(rid); |
| 584 | return rid; |
| 585 | } |
| 586 | |
| 587 | /* |
| 588 | ** This is the simple common case for inserting content into the |
| 589 | ** repository. pBlob is the content to be inserted. |
| 590 | ** |
| 591 | ** pBlob is uncompressed and is not deltaed. It is exactly the content |
| 592 | ** to be inserted. |
| 593 | ** |
| 594 | ** The original content of pBlob is not disturbed. The caller continues |
| 595 | ** to be responsible for pBlob. This routine does *not* take over |
| 596 | ** responsiblity for freeing pBlob. |
| 597 | */ |
| 598 | int content_put(Blob *pBlob){ |
| 599 | return content_put_ex(pBlob, 0, 0, 0, 0); |
| 600 | } |
| 601 | |
| 602 | |
| 603 | /* |
| 604 | ** Create a new phantom with the given UUID and return its artifact ID. |
| 605 | */ |
| 606 | int content_new(const char *zUuid, int isPrivate){ |
| 607 | int rid; |
| 608 | static Stmt s1, s2, s3; |
| 609 | |
| 610 | assert( g.repositoryOpen ); |
| 611 | db_begin_transaction(); |
| @@ -599,11 +623,11 @@ | |
| 623 | db_static_prepare(&s2, |
| 624 | "INSERT INTO phantom VALUES(:rid)" |
| 625 | ); |
| 626 | db_bind_int(&s2, ":rid", rid); |
| 627 | db_exec(&s2); |
| 628 | if( g.markPrivate || isPrivate ){ |
| 629 | db_multi_exec("INSERT INTO private VALUES(%d)", rid); |
| 630 | }else{ |
| 631 | db_static_prepare(&s3, |
| 632 | "INSERT INTO unclustered VALUES(:rid)" |
| 633 | ); |
| @@ -626,11 +650,11 @@ | |
| 650 | Blob content; |
| 651 | if( g.argc!=3 ) usage("FILENAME"); |
| 652 | db_must_be_within_tree(); |
| 653 | user_select(); |
| 654 | blob_read_from_file(&content, g.argv[2]); |
| 655 | rid = content_put(&content); |
| 656 | printf("inserted as record %d\n", rid); |
| 657 | } |
| 658 | |
| 659 | /* |
| 660 | ** Make sure the content at rid is the original content and is not a |
| 661 |
M
src/db.c
+1
-1
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1118,11 +1118,11 @@ | ||
| 1118 | 1118 | blob_appendf(&manifest, "T *sym-trunk *\n"); |
| 1119 | 1119 | blob_appendf(&manifest, "U %F\n", g.zLogin); |
| 1120 | 1120 | md5sum_blob(&manifest, &hash); |
| 1121 | 1121 | blob_appendf(&manifest, "Z %b\n", &hash); |
| 1122 | 1122 | blob_reset(&hash); |
| 1123 | - rid = content_put(&manifest, 0, 0, 0); | |
| 1123 | + rid = content_put(&manifest); | |
| 1124 | 1124 | manifest_crosslink(rid, &manifest); |
| 1125 | 1125 | } |
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | 1128 | /* |
| 1129 | 1129 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1118,11 +1118,11 @@ | |
| 1118 | blob_appendf(&manifest, "T *sym-trunk *\n"); |
| 1119 | blob_appendf(&manifest, "U %F\n", g.zLogin); |
| 1120 | md5sum_blob(&manifest, &hash); |
| 1121 | blob_appendf(&manifest, "Z %b\n", &hash); |
| 1122 | blob_reset(&hash); |
| 1123 | rid = content_put(&manifest, 0, 0, 0); |
| 1124 | manifest_crosslink(rid, &manifest); |
| 1125 | } |
| 1126 | } |
| 1127 | |
| 1128 | /* |
| 1129 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1118,11 +1118,11 @@ | |
| 1118 | blob_appendf(&manifest, "T *sym-trunk *\n"); |
| 1119 | blob_appendf(&manifest, "U %F\n", g.zLogin); |
| 1120 | md5sum_blob(&manifest, &hash); |
| 1121 | blob_appendf(&manifest, "Z %b\n", &hash); |
| 1122 | blob_reset(&hash); |
| 1123 | rid = content_put(&manifest); |
| 1124 | manifest_crosslink(rid, &manifest); |
| 1125 | } |
| 1126 | } |
| 1127 | |
| 1128 | /* |
| 1129 |
+1
-1
| --- src/event.c | ||
| +++ src/event.c | ||
| @@ -343,11 +343,11 @@ | ||
| 343 | 343 | } |
| 344 | 344 | blob_appendf(&event, "W %d\n%s\n", strlen(zBody), zBody); |
| 345 | 345 | md5sum_blob(&event, &cksum); |
| 346 | 346 | blob_appendf(&event, "Z %b\n", &cksum); |
| 347 | 347 | blob_reset(&cksum); |
| 348 | - nrid = content_put(&event, 0, 0, 0); | |
| 348 | + nrid = content_put(&event); | |
| 349 | 349 | db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid); |
| 350 | 350 | manifest_crosslink(nrid, &event); |
| 351 | 351 | assert( blob_is_reset(&event) ); |
| 352 | 352 | content_deltify(rid, nrid, 0); |
| 353 | 353 | db_end_transaction(0); |
| 354 | 354 |
| --- src/event.c | |
| +++ src/event.c | |
| @@ -343,11 +343,11 @@ | |
| 343 | } |
| 344 | blob_appendf(&event, "W %d\n%s\n", strlen(zBody), zBody); |
| 345 | md5sum_blob(&event, &cksum); |
| 346 | blob_appendf(&event, "Z %b\n", &cksum); |
| 347 | blob_reset(&cksum); |
| 348 | nrid = content_put(&event, 0, 0, 0); |
| 349 | db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid); |
| 350 | manifest_crosslink(nrid, &event); |
| 351 | assert( blob_is_reset(&event) ); |
| 352 | content_deltify(rid, nrid, 0); |
| 353 | db_end_transaction(0); |
| 354 |
| --- src/event.c | |
| +++ src/event.c | |
| @@ -343,11 +343,11 @@ | |
| 343 | } |
| 344 | blob_appendf(&event, "W %d\n%s\n", strlen(zBody), zBody); |
| 345 | md5sum_blob(&event, &cksum); |
| 346 | blob_appendf(&event, "Z %b\n", &cksum); |
| 347 | blob_reset(&cksum); |
| 348 | nrid = content_put(&event); |
| 349 | db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid); |
| 350 | manifest_crosslink(nrid, &event); |
| 351 | assert( blob_is_reset(&event) ); |
| 352 | content_deltify(rid, nrid, 0); |
| 353 | db_end_transaction(0); |
| 354 |
+1
-1
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -1652,11 +1652,11 @@ | ||
| 1652 | 1652 | blob_appendf(&ctrl, "U %F\n", g.zLogin); |
| 1653 | 1653 | md5sum_blob(&ctrl, &cksum); |
| 1654 | 1654 | blob_appendf(&ctrl, "Z %b\n", &cksum); |
| 1655 | 1655 | db_begin_transaction(); |
| 1656 | 1656 | g.markPrivate = content_is_private(rid); |
| 1657 | - nrid = content_put(&ctrl, 0, 0, 0); | |
| 1657 | + nrid = content_put(&ctrl); | |
| 1658 | 1658 | manifest_crosslink(nrid, &ctrl); |
| 1659 | 1659 | assert( blob_is_reset(&ctrl) ); |
| 1660 | 1660 | db_end_transaction(0); |
| 1661 | 1661 | } |
| 1662 | 1662 | cgi_redirectf("ci?name=%s", zUuid); |
| 1663 | 1663 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -1652,11 +1652,11 @@ | |
| 1652 | blob_appendf(&ctrl, "U %F\n", g.zLogin); |
| 1653 | md5sum_blob(&ctrl, &cksum); |
| 1654 | blob_appendf(&ctrl, "Z %b\n", &cksum); |
| 1655 | db_begin_transaction(); |
| 1656 | g.markPrivate = content_is_private(rid); |
| 1657 | nrid = content_put(&ctrl, 0, 0, 0); |
| 1658 | manifest_crosslink(nrid, &ctrl); |
| 1659 | assert( blob_is_reset(&ctrl) ); |
| 1660 | db_end_transaction(0); |
| 1661 | } |
| 1662 | cgi_redirectf("ci?name=%s", zUuid); |
| 1663 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -1652,11 +1652,11 @@ | |
| 1652 | blob_appendf(&ctrl, "U %F\n", g.zLogin); |
| 1653 | md5sum_blob(&ctrl, &cksum); |
| 1654 | blob_appendf(&ctrl, "Z %b\n", &cksum); |
| 1655 | db_begin_transaction(); |
| 1656 | g.markPrivate = content_is_private(rid); |
| 1657 | nrid = content_put(&ctrl); |
| 1658 | manifest_crosslink(nrid, &ctrl); |
| 1659 | assert( blob_is_reset(&ctrl) ); |
| 1660 | db_end_transaction(0); |
| 1661 | } |
| 1662 | cgi_redirectf("ci?name=%s", zUuid); |
| 1663 |
+1
-1
| --- src/rebuild.c | ||
| +++ src/rebuild.c | ||
| @@ -596,11 +596,11 @@ | ||
| 596 | 596 | blob_appendf(&path, "%s", zSubpath); |
| 597 | 597 | if( blob_read_from_file(&aContent, blob_str(&path))==-1 ){ |
| 598 | 598 | fossil_panic("some unknown error occurred while reading \"%s\"", |
| 599 | 599 | blob_str(&path)); |
| 600 | 600 | } |
| 601 | - content_put(&aContent, 0, 0, 0); | |
| 601 | + content_put(&aContent); | |
| 602 | 602 | blob_reset(&path); |
| 603 | 603 | blob_reset(&aContent); |
| 604 | 604 | free(zSubpath); |
| 605 | 605 | printf("\r%d", ++nFileRead); |
| 606 | 606 | fflush(stdout); |
| 607 | 607 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -596,11 +596,11 @@ | |
| 596 | blob_appendf(&path, "%s", zSubpath); |
| 597 | if( blob_read_from_file(&aContent, blob_str(&path))==-1 ){ |
| 598 | fossil_panic("some unknown error occurred while reading \"%s\"", |
| 599 | blob_str(&path)); |
| 600 | } |
| 601 | content_put(&aContent, 0, 0, 0); |
| 602 | blob_reset(&path); |
| 603 | blob_reset(&aContent); |
| 604 | free(zSubpath); |
| 605 | printf("\r%d", ++nFileRead); |
| 606 | fflush(stdout); |
| 607 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -596,11 +596,11 @@ | |
| 596 | blob_appendf(&path, "%s", zSubpath); |
| 597 | if( blob_read_from_file(&aContent, blob_str(&path))==-1 ){ |
| 598 | fossil_panic("some unknown error occurred while reading \"%s\"", |
| 599 | blob_str(&path)); |
| 600 | } |
| 601 | content_put(&aContent); |
| 602 | blob_reset(&path); |
| 603 | blob_reset(&aContent); |
| 604 | free(zSubpath); |
| 605 | printf("\r%d", ++nFileRead); |
| 606 | fflush(stdout); |
| 607 |
+1
-1
| --- src/tag.c | ||
| +++ src/tag.c | ||
| @@ -309,11 +309,11 @@ | ||
| 309 | 309 | blob_appendf(&ctrl, "\n"); |
| 310 | 310 | } |
| 311 | 311 | blob_appendf(&ctrl, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin); |
| 312 | 312 | md5sum_blob(&ctrl, &cksum); |
| 313 | 313 | blob_appendf(&ctrl, "Z %b\n", &cksum); |
| 314 | - nrid = content_put(&ctrl, 0, 0, 0); | |
| 314 | + nrid = content_put(&ctrl); | |
| 315 | 315 | manifest_crosslink(nrid, &ctrl); |
| 316 | 316 | assert( blob_is_reset(&ctrl) ); |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | /* |
| 320 | 320 |
| --- src/tag.c | |
| +++ src/tag.c | |
| @@ -309,11 +309,11 @@ | |
| 309 | blob_appendf(&ctrl, "\n"); |
| 310 | } |
| 311 | blob_appendf(&ctrl, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin); |
| 312 | md5sum_blob(&ctrl, &cksum); |
| 313 | blob_appendf(&ctrl, "Z %b\n", &cksum); |
| 314 | nrid = content_put(&ctrl, 0, 0, 0); |
| 315 | manifest_crosslink(nrid, &ctrl); |
| 316 | assert( blob_is_reset(&ctrl) ); |
| 317 | } |
| 318 | |
| 319 | /* |
| 320 |
| --- src/tag.c | |
| +++ src/tag.c | |
| @@ -309,11 +309,11 @@ | |
| 309 | blob_appendf(&ctrl, "\n"); |
| 310 | } |
| 311 | blob_appendf(&ctrl, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin); |
| 312 | md5sum_blob(&ctrl, &cksum); |
| 313 | blob_appendf(&ctrl, "Z %b\n", &cksum); |
| 314 | nrid = content_put(&ctrl); |
| 315 | manifest_crosslink(nrid, &ctrl); |
| 316 | assert( blob_is_reset(&ctrl) ); |
| 317 | } |
| 318 | |
| 319 | /* |
| 320 |
+2
-2
| --- src/tkt.c | ||
| +++ src/tkt.c | ||
| @@ -479,11 +479,11 @@ | ||
| 479 | 479 | }else if( g.thTrace ){ |
| 480 | 480 | Th_Trace("submit_ticket {\n<blockquote><pre>\n%h\n</pre></blockquote>\n" |
| 481 | 481 | "}<br />\n", |
| 482 | 482 | blob_str(&tktchng)); |
| 483 | 483 | }else{ |
| 484 | - rid = content_put(&tktchng, 0, 0, 0); | |
| 484 | + rid = content_put(&tktchng); | |
| 485 | 485 | if( rid==0 ){ |
| 486 | 486 | fossil_panic("trouble committing ticket: %s", g.zErrMsg); |
| 487 | 487 | } |
| 488 | 488 | manifest_crosslink_begin(); |
| 489 | 489 | manifest_crosslink(rid, &tktchng); |
| @@ -1056,11 +1056,11 @@ | ||
| 1056 | 1056 | } |
| 1057 | 1057 | blob_appendf(&tktchng, "K %s\n", zTktUuid); |
| 1058 | 1058 | blob_appendf(&tktchng, "U %F\n", g.zLogin); |
| 1059 | 1059 | md5sum_blob(&tktchng, &cksum); |
| 1060 | 1060 | blob_appendf(&tktchng, "Z %b\n", &cksum); |
| 1061 | - rid = content_put(&tktchng, 0, 0, 0); | |
| 1061 | + rid = content_put(&tktchng); | |
| 1062 | 1062 | if( rid==0 ){ |
| 1063 | 1063 | fossil_panic("trouble committing ticket: %s", g.zErrMsg); |
| 1064 | 1064 | } |
| 1065 | 1065 | manifest_crosslink_begin(); |
| 1066 | 1066 | manifest_crosslink(rid, &tktchng); |
| 1067 | 1067 |
| --- src/tkt.c | |
| +++ src/tkt.c | |
| @@ -479,11 +479,11 @@ | |
| 479 | }else if( g.thTrace ){ |
| 480 | Th_Trace("submit_ticket {\n<blockquote><pre>\n%h\n</pre></blockquote>\n" |
| 481 | "}<br />\n", |
| 482 | blob_str(&tktchng)); |
| 483 | }else{ |
| 484 | rid = content_put(&tktchng, 0, 0, 0); |
| 485 | if( rid==0 ){ |
| 486 | fossil_panic("trouble committing ticket: %s", g.zErrMsg); |
| 487 | } |
| 488 | manifest_crosslink_begin(); |
| 489 | manifest_crosslink(rid, &tktchng); |
| @@ -1056,11 +1056,11 @@ | |
| 1056 | } |
| 1057 | blob_appendf(&tktchng, "K %s\n", zTktUuid); |
| 1058 | blob_appendf(&tktchng, "U %F\n", g.zLogin); |
| 1059 | md5sum_blob(&tktchng, &cksum); |
| 1060 | blob_appendf(&tktchng, "Z %b\n", &cksum); |
| 1061 | rid = content_put(&tktchng, 0, 0, 0); |
| 1062 | if( rid==0 ){ |
| 1063 | fossil_panic("trouble committing ticket: %s", g.zErrMsg); |
| 1064 | } |
| 1065 | manifest_crosslink_begin(); |
| 1066 | manifest_crosslink(rid, &tktchng); |
| 1067 |
| --- src/tkt.c | |
| +++ src/tkt.c | |
| @@ -479,11 +479,11 @@ | |
| 479 | }else if( g.thTrace ){ |
| 480 | Th_Trace("submit_ticket {\n<blockquote><pre>\n%h\n</pre></blockquote>\n" |
| 481 | "}<br />\n", |
| 482 | blob_str(&tktchng)); |
| 483 | }else{ |
| 484 | rid = content_put(&tktchng); |
| 485 | if( rid==0 ){ |
| 486 | fossil_panic("trouble committing ticket: %s", g.zErrMsg); |
| 487 | } |
| 488 | manifest_crosslink_begin(); |
| 489 | manifest_crosslink(rid, &tktchng); |
| @@ -1056,11 +1056,11 @@ | |
| 1056 | } |
| 1057 | blob_appendf(&tktchng, "K %s\n", zTktUuid); |
| 1058 | blob_appendf(&tktchng, "U %F\n", g.zLogin); |
| 1059 | md5sum_blob(&tktchng, &cksum); |
| 1060 | blob_appendf(&tktchng, "Z %b\n", &cksum); |
| 1061 | rid = content_put(&tktchng); |
| 1062 | if( rid==0 ){ |
| 1063 | fossil_panic("trouble committing ticket: %s", g.zErrMsg); |
| 1064 | } |
| 1065 | manifest_crosslink_begin(); |
| 1066 | manifest_crosslink(rid, &tktchng); |
| 1067 |
+4
-3
| --- src/vfile.c | ||
| +++ src/vfile.c | ||
| @@ -50,12 +50,13 @@ | ||
| 50 | 50 | ** does not exist, then return 0. |
| 51 | 51 | ** |
| 52 | 52 | ** For this routine, the UUID must be exact. For a match against |
| 53 | 53 | ** user input with mixed case, use resolve_uuid(). |
| 54 | 54 | ** |
| 55 | -** If the UUID is not found and phantomize is 1, then attempt to | |
| 56 | -** create a phantom record. | |
| 55 | +** If the UUID is not found and phantomize is 1 or 2, then attempt to | |
| 56 | +** create a phantom record. A private phantom is created for 2 and | |
| 57 | +** a public phantom is created for 1. | |
| 57 | 58 | */ |
| 58 | 59 | int uuid_to_rid(const char *zUuid, int phantomize){ |
| 59 | 60 | int rid, sz; |
| 60 | 61 | char z[UUID_SIZE+1]; |
| 61 | 62 | |
| @@ -65,11 +66,11 @@ | ||
| 65 | 66 | } |
| 66 | 67 | memcpy(z, zUuid, UUID_SIZE+1); |
| 67 | 68 | canonical16(z, sz); |
| 68 | 69 | rid = fast_uuid_to_rid(z); |
| 69 | 70 | if( rid==0 && phantomize ){ |
| 70 | - rid = content_new(zUuid); | |
| 71 | + rid = content_new(zUuid, phantomize-1); | |
| 71 | 72 | } |
| 72 | 73 | return rid; |
| 73 | 74 | } |
| 74 | 75 | |
| 75 | 76 | /* |
| 76 | 77 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -50,12 +50,13 @@ | |
| 50 | ** does not exist, then return 0. |
| 51 | ** |
| 52 | ** For this routine, the UUID must be exact. For a match against |
| 53 | ** user input with mixed case, use resolve_uuid(). |
| 54 | ** |
| 55 | ** If the UUID is not found and phantomize is 1, then attempt to |
| 56 | ** create a phantom record. |
| 57 | */ |
| 58 | int uuid_to_rid(const char *zUuid, int phantomize){ |
| 59 | int rid, sz; |
| 60 | char z[UUID_SIZE+1]; |
| 61 | |
| @@ -65,11 +66,11 @@ | |
| 65 | } |
| 66 | memcpy(z, zUuid, UUID_SIZE+1); |
| 67 | canonical16(z, sz); |
| 68 | rid = fast_uuid_to_rid(z); |
| 69 | if( rid==0 && phantomize ){ |
| 70 | rid = content_new(zUuid); |
| 71 | } |
| 72 | return rid; |
| 73 | } |
| 74 | |
| 75 | /* |
| 76 |
| --- src/vfile.c | |
| +++ src/vfile.c | |
| @@ -50,12 +50,13 @@ | |
| 50 | ** does not exist, then return 0. |
| 51 | ** |
| 52 | ** For this routine, the UUID must be exact. For a match against |
| 53 | ** user input with mixed case, use resolve_uuid(). |
| 54 | ** |
| 55 | ** If the UUID is not found and phantomize is 1 or 2, then attempt to |
| 56 | ** create a phantom record. A private phantom is created for 2 and |
| 57 | ** a public phantom is created for 1. |
| 58 | */ |
| 59 | int uuid_to_rid(const char *zUuid, int phantomize){ |
| 60 | int rid, sz; |
| 61 | char z[UUID_SIZE+1]; |
| 62 | |
| @@ -65,11 +66,11 @@ | |
| 66 | } |
| 67 | memcpy(z, zUuid, UUID_SIZE+1); |
| 68 | canonical16(z, sz); |
| 69 | rid = fast_uuid_to_rid(z); |
| 70 | if( rid==0 && phantomize ){ |
| 71 | rid = content_new(zUuid, phantomize-1); |
| 72 | } |
| 73 | return rid; |
| 74 | } |
| 75 | |
| 76 | /* |
| 77 |
+3
-3
| --- src/wiki.c | ||
| +++ src/wiki.c | ||
| @@ -321,11 +321,11 @@ | ||
| 321 | 321 | } |
| 322 | 322 | blob_appendf(&wiki, "W %d\n%s\n", strlen(zBody), zBody); |
| 323 | 323 | md5sum_blob(&wiki, &cksum); |
| 324 | 324 | blob_appendf(&wiki, "Z %b\n", &cksum); |
| 325 | 325 | blob_reset(&cksum); |
| 326 | - nrid = content_put(&wiki, 0, 0, 0); | |
| 326 | + nrid = content_put(&wiki); | |
| 327 | 327 | db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid); |
| 328 | 328 | manifest_crosslink(nrid, &wiki); |
| 329 | 329 | assert( blob_is_reset(&wiki) ); |
| 330 | 330 | content_deltify(rid, nrid, 0); |
| 331 | 331 | } |
| @@ -493,11 +493,11 @@ | ||
| 493 | 493 | appendRemark(&body); |
| 494 | 494 | blob_appendf(&wiki, "W %d\n%s\n", blob_size(&body), blob_str(&body)); |
| 495 | 495 | md5sum_blob(&wiki, &cksum); |
| 496 | 496 | blob_appendf(&wiki, "Z %b\n", &cksum); |
| 497 | 497 | blob_reset(&cksum); |
| 498 | - nrid = content_put(&wiki, 0, 0, 0); | |
| 498 | + nrid = content_put(&wiki); | |
| 499 | 499 | db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid); |
| 500 | 500 | manifest_crosslink(nrid, &wiki); |
| 501 | 501 | assert( blob_is_reset(&wiki) ); |
| 502 | 502 | content_deltify(rid, nrid, 0); |
| 503 | 503 | db_end_transaction(0); |
| @@ -817,11 +817,11 @@ | ||
| 817 | 817 | blob_str(pContent) ); |
| 818 | 818 | md5sum_blob(&wiki, &cksum); |
| 819 | 819 | blob_appendf(&wiki, "Z %b\n", &cksum); |
| 820 | 820 | blob_reset(&cksum); |
| 821 | 821 | db_begin_transaction(); |
| 822 | - nrid = content_put( &wiki, 0, 0, 0); | |
| 822 | + nrid = content_put( &wiki); | |
| 823 | 823 | db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid); |
| 824 | 824 | manifest_crosslink(nrid,&wiki); |
| 825 | 825 | assert( blob_is_reset(&wiki) ); |
| 826 | 826 | content_deltify(rid,nrid,0); |
| 827 | 827 | db_end_transaction(0); |
| 828 | 828 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -321,11 +321,11 @@ | |
| 321 | } |
| 322 | blob_appendf(&wiki, "W %d\n%s\n", strlen(zBody), zBody); |
| 323 | md5sum_blob(&wiki, &cksum); |
| 324 | blob_appendf(&wiki, "Z %b\n", &cksum); |
| 325 | blob_reset(&cksum); |
| 326 | nrid = content_put(&wiki, 0, 0, 0); |
| 327 | db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid); |
| 328 | manifest_crosslink(nrid, &wiki); |
| 329 | assert( blob_is_reset(&wiki) ); |
| 330 | content_deltify(rid, nrid, 0); |
| 331 | } |
| @@ -493,11 +493,11 @@ | |
| 493 | appendRemark(&body); |
| 494 | blob_appendf(&wiki, "W %d\n%s\n", blob_size(&body), blob_str(&body)); |
| 495 | md5sum_blob(&wiki, &cksum); |
| 496 | blob_appendf(&wiki, "Z %b\n", &cksum); |
| 497 | blob_reset(&cksum); |
| 498 | nrid = content_put(&wiki, 0, 0, 0); |
| 499 | db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid); |
| 500 | manifest_crosslink(nrid, &wiki); |
| 501 | assert( blob_is_reset(&wiki) ); |
| 502 | content_deltify(rid, nrid, 0); |
| 503 | db_end_transaction(0); |
| @@ -817,11 +817,11 @@ | |
| 817 | blob_str(pContent) ); |
| 818 | md5sum_blob(&wiki, &cksum); |
| 819 | blob_appendf(&wiki, "Z %b\n", &cksum); |
| 820 | blob_reset(&cksum); |
| 821 | db_begin_transaction(); |
| 822 | nrid = content_put( &wiki, 0, 0, 0); |
| 823 | db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid); |
| 824 | manifest_crosslink(nrid,&wiki); |
| 825 | assert( blob_is_reset(&wiki) ); |
| 826 | content_deltify(rid,nrid,0); |
| 827 | db_end_transaction(0); |
| 828 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -321,11 +321,11 @@ | |
| 321 | } |
| 322 | blob_appendf(&wiki, "W %d\n%s\n", strlen(zBody), zBody); |
| 323 | md5sum_blob(&wiki, &cksum); |
| 324 | blob_appendf(&wiki, "Z %b\n", &cksum); |
| 325 | blob_reset(&cksum); |
| 326 | nrid = content_put(&wiki); |
| 327 | db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid); |
| 328 | manifest_crosslink(nrid, &wiki); |
| 329 | assert( blob_is_reset(&wiki) ); |
| 330 | content_deltify(rid, nrid, 0); |
| 331 | } |
| @@ -493,11 +493,11 @@ | |
| 493 | appendRemark(&body); |
| 494 | blob_appendf(&wiki, "W %d\n%s\n", blob_size(&body), blob_str(&body)); |
| 495 | md5sum_blob(&wiki, &cksum); |
| 496 | blob_appendf(&wiki, "Z %b\n", &cksum); |
| 497 | blob_reset(&cksum); |
| 498 | nrid = content_put(&wiki); |
| 499 | db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid); |
| 500 | manifest_crosslink(nrid, &wiki); |
| 501 | assert( blob_is_reset(&wiki) ); |
| 502 | content_deltify(rid, nrid, 0); |
| 503 | db_end_transaction(0); |
| @@ -817,11 +817,11 @@ | |
| 817 | blob_str(pContent) ); |
| 818 | md5sum_blob(&wiki, &cksum); |
| 819 | blob_appendf(&wiki, "Z %b\n", &cksum); |
| 820 | blob_reset(&cksum); |
| 821 | db_begin_transaction(); |
| 822 | nrid = content_put( &wiki); |
| 823 | db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid); |
| 824 | manifest_crosslink(nrid,&wiki); |
| 825 | assert( blob_is_reset(&wiki) ); |
| 826 | content_deltify(rid,nrid,0); |
| 827 | db_end_transaction(0); |
| 828 |
+8
-8
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -62,11 +62,11 @@ | ||
| 62 | 62 | }else{ |
| 63 | 63 | rid = 0; |
| 64 | 64 | } |
| 65 | 65 | db_reset(&q); |
| 66 | 66 | if( rid==0 && phantomize ){ |
| 67 | - rid = content_new(blob_str(pUuid)); | |
| 67 | + rid = content_new(blob_str(pUuid), 0); | |
| 68 | 68 | } |
| 69 | 69 | return rid; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /* |
| @@ -132,20 +132,20 @@ | ||
| 132 | 132 | pXfer->nDeltaRcvd++; |
| 133 | 133 | }else{ |
| 134 | 134 | srcid = 0; |
| 135 | 135 | pXfer->nFileRcvd++; |
| 136 | 136 | } |
| 137 | - rid = content_put(&content, blob_str(&pXfer->aToken[1]), srcid, 0); | |
| 137 | + rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid, 0, 0); | |
| 138 | 138 | remote_has(rid); |
| 139 | 139 | blob_reset(&content); |
| 140 | 140 | return; |
| 141 | 141 | } |
| 142 | 142 | if( pXfer->nToken==4 ){ |
| 143 | 143 | Blob src, next; |
| 144 | 144 | srcid = rid_from_uuid(&pXfer->aToken[2], 1); |
| 145 | 145 | if( content_get(srcid, &src)==0 ){ |
| 146 | - rid = content_put(&content, blob_str(&pXfer->aToken[1]), srcid, 0); | |
| 146 | + rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid, 0, 0); | |
| 147 | 147 | pXfer->nDanglingFile++; |
| 148 | 148 | db_multi_exec("DELETE FROM phantom WHERE rid=%d", rid); |
| 149 | 149 | content_make_public(rid); |
| 150 | 150 | return; |
| 151 | 151 | } |
| @@ -159,11 +159,11 @@ | ||
| 159 | 159 | } |
| 160 | 160 | sha1sum_blob(&content, &hash); |
| 161 | 161 | if( !blob_eq_str(&pXfer->aToken[1], blob_str(&hash), -1) ){ |
| 162 | 162 | blob_appendf(&pXfer->err, "content does not match sha1 hash"); |
| 163 | 163 | } |
| 164 | - rid = content_put(&content, blob_str(&hash), 0, 0); | |
| 164 | + rid = content_put_ex(&content, blob_str(&hash), 0, 0, 0); | |
| 165 | 165 | blob_reset(&hash); |
| 166 | 166 | if( rid==0 ){ |
| 167 | 167 | blob_appendf(&pXfer->err, "%s", g.zErrMsg); |
| 168 | 168 | blob_reset(&content); |
| 169 | 169 | }else{ |
| @@ -226,11 +226,11 @@ | ||
| 226 | 226 | pXfer->nDeltaRcvd++; |
| 227 | 227 | }else{ |
| 228 | 228 | srcid = 0; |
| 229 | 229 | pXfer->nFileRcvd++; |
| 230 | 230 | } |
| 231 | - rid = content_put(&content, blob_str(&pXfer->aToken[1]), srcid, szC); | |
| 231 | + rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid, szC, 0); | |
| 232 | 232 | remote_has(rid); |
| 233 | 233 | blob_reset(&content); |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /* |
| @@ -617,11 +617,11 @@ | ||
| 617 | 617 | nRow++; |
| 618 | 618 | if( nRow>=800 && nUncl>nRow+100 ){ |
| 619 | 619 | md5sum_blob(&cluster, &cksum); |
| 620 | 620 | blob_appendf(&cluster, "Z %b\n", &cksum); |
| 621 | 621 | blob_reset(&cksum); |
| 622 | - rid = content_put(&cluster, 0, 0, 0); | |
| 622 | + rid = content_put(&cluster); | |
| 623 | 623 | blob_reset(&cluster); |
| 624 | 624 | nUncl -= nRow; |
| 625 | 625 | nRow = 0; |
| 626 | 626 | blob_appendf(&deleteWhere, ",%d", rid); |
| 627 | 627 | } |
| @@ -634,11 +634,11 @@ | ||
| 634 | 634 | blob_reset(&deleteWhere); |
| 635 | 635 | if( nRow>0 ){ |
| 636 | 636 | md5sum_blob(&cluster, &cksum); |
| 637 | 637 | blob_appendf(&cluster, "Z %b\n", &cksum); |
| 638 | 638 | blob_reset(&cksum); |
| 639 | - content_put(&cluster, 0, 0, 0); | |
| 639 | + content_put(&cluster); | |
| 640 | 640 | blob_reset(&cluster); |
| 641 | 641 | } |
| 642 | 642 | } |
| 643 | 643 | } |
| 644 | 644 | |
| @@ -1368,11 +1368,11 @@ | ||
| 1368 | 1368 | ){ |
| 1369 | 1369 | int rid = rid_from_uuid(&xfer.aToken[1], 0); |
| 1370 | 1370 | if( rid>0 ){ |
| 1371 | 1371 | content_make_public(rid); |
| 1372 | 1372 | }else if( pullFlag || cloneFlag ){ |
| 1373 | - rid = content_new(blob_str(&xfer.aToken[1])); | |
| 1373 | + rid = content_new(blob_str(&xfer.aToken[1]), 0); | |
| 1374 | 1374 | if( rid ) newPhantom = 1; |
| 1375 | 1375 | } |
| 1376 | 1376 | remote_has(rid); |
| 1377 | 1377 | }else |
| 1378 | 1378 | |
| 1379 | 1379 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -62,11 +62,11 @@ | |
| 62 | }else{ |
| 63 | rid = 0; |
| 64 | } |
| 65 | db_reset(&q); |
| 66 | if( rid==0 && phantomize ){ |
| 67 | rid = content_new(blob_str(pUuid)); |
| 68 | } |
| 69 | return rid; |
| 70 | } |
| 71 | |
| 72 | /* |
| @@ -132,20 +132,20 @@ | |
| 132 | pXfer->nDeltaRcvd++; |
| 133 | }else{ |
| 134 | srcid = 0; |
| 135 | pXfer->nFileRcvd++; |
| 136 | } |
| 137 | rid = content_put(&content, blob_str(&pXfer->aToken[1]), srcid, 0); |
| 138 | remote_has(rid); |
| 139 | blob_reset(&content); |
| 140 | return; |
| 141 | } |
| 142 | if( pXfer->nToken==4 ){ |
| 143 | Blob src, next; |
| 144 | srcid = rid_from_uuid(&pXfer->aToken[2], 1); |
| 145 | if( content_get(srcid, &src)==0 ){ |
| 146 | rid = content_put(&content, blob_str(&pXfer->aToken[1]), srcid, 0); |
| 147 | pXfer->nDanglingFile++; |
| 148 | db_multi_exec("DELETE FROM phantom WHERE rid=%d", rid); |
| 149 | content_make_public(rid); |
| 150 | return; |
| 151 | } |
| @@ -159,11 +159,11 @@ | |
| 159 | } |
| 160 | sha1sum_blob(&content, &hash); |
| 161 | if( !blob_eq_str(&pXfer->aToken[1], blob_str(&hash), -1) ){ |
| 162 | blob_appendf(&pXfer->err, "content does not match sha1 hash"); |
| 163 | } |
| 164 | rid = content_put(&content, blob_str(&hash), 0, 0); |
| 165 | blob_reset(&hash); |
| 166 | if( rid==0 ){ |
| 167 | blob_appendf(&pXfer->err, "%s", g.zErrMsg); |
| 168 | blob_reset(&content); |
| 169 | }else{ |
| @@ -226,11 +226,11 @@ | |
| 226 | pXfer->nDeltaRcvd++; |
| 227 | }else{ |
| 228 | srcid = 0; |
| 229 | pXfer->nFileRcvd++; |
| 230 | } |
| 231 | rid = content_put(&content, blob_str(&pXfer->aToken[1]), srcid, szC); |
| 232 | remote_has(rid); |
| 233 | blob_reset(&content); |
| 234 | } |
| 235 | |
| 236 | /* |
| @@ -617,11 +617,11 @@ | |
| 617 | nRow++; |
| 618 | if( nRow>=800 && nUncl>nRow+100 ){ |
| 619 | md5sum_blob(&cluster, &cksum); |
| 620 | blob_appendf(&cluster, "Z %b\n", &cksum); |
| 621 | blob_reset(&cksum); |
| 622 | rid = content_put(&cluster, 0, 0, 0); |
| 623 | blob_reset(&cluster); |
| 624 | nUncl -= nRow; |
| 625 | nRow = 0; |
| 626 | blob_appendf(&deleteWhere, ",%d", rid); |
| 627 | } |
| @@ -634,11 +634,11 @@ | |
| 634 | blob_reset(&deleteWhere); |
| 635 | if( nRow>0 ){ |
| 636 | md5sum_blob(&cluster, &cksum); |
| 637 | blob_appendf(&cluster, "Z %b\n", &cksum); |
| 638 | blob_reset(&cksum); |
| 639 | content_put(&cluster, 0, 0, 0); |
| 640 | blob_reset(&cluster); |
| 641 | } |
| 642 | } |
| 643 | } |
| 644 | |
| @@ -1368,11 +1368,11 @@ | |
| 1368 | ){ |
| 1369 | int rid = rid_from_uuid(&xfer.aToken[1], 0); |
| 1370 | if( rid>0 ){ |
| 1371 | content_make_public(rid); |
| 1372 | }else if( pullFlag || cloneFlag ){ |
| 1373 | rid = content_new(blob_str(&xfer.aToken[1])); |
| 1374 | if( rid ) newPhantom = 1; |
| 1375 | } |
| 1376 | remote_has(rid); |
| 1377 | }else |
| 1378 | |
| 1379 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -62,11 +62,11 @@ | |
| 62 | }else{ |
| 63 | rid = 0; |
| 64 | } |
| 65 | db_reset(&q); |
| 66 | if( rid==0 && phantomize ){ |
| 67 | rid = content_new(blob_str(pUuid), 0); |
| 68 | } |
| 69 | return rid; |
| 70 | } |
| 71 | |
| 72 | /* |
| @@ -132,20 +132,20 @@ | |
| 132 | pXfer->nDeltaRcvd++; |
| 133 | }else{ |
| 134 | srcid = 0; |
| 135 | pXfer->nFileRcvd++; |
| 136 | } |
| 137 | rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid, 0, 0); |
| 138 | remote_has(rid); |
| 139 | blob_reset(&content); |
| 140 | return; |
| 141 | } |
| 142 | if( pXfer->nToken==4 ){ |
| 143 | Blob src, next; |
| 144 | srcid = rid_from_uuid(&pXfer->aToken[2], 1); |
| 145 | if( content_get(srcid, &src)==0 ){ |
| 146 | rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid, 0, 0); |
| 147 | pXfer->nDanglingFile++; |
| 148 | db_multi_exec("DELETE FROM phantom WHERE rid=%d", rid); |
| 149 | content_make_public(rid); |
| 150 | return; |
| 151 | } |
| @@ -159,11 +159,11 @@ | |
| 159 | } |
| 160 | sha1sum_blob(&content, &hash); |
| 161 | if( !blob_eq_str(&pXfer->aToken[1], blob_str(&hash), -1) ){ |
| 162 | blob_appendf(&pXfer->err, "content does not match sha1 hash"); |
| 163 | } |
| 164 | rid = content_put_ex(&content, blob_str(&hash), 0, 0, 0); |
| 165 | blob_reset(&hash); |
| 166 | if( rid==0 ){ |
| 167 | blob_appendf(&pXfer->err, "%s", g.zErrMsg); |
| 168 | blob_reset(&content); |
| 169 | }else{ |
| @@ -226,11 +226,11 @@ | |
| 226 | pXfer->nDeltaRcvd++; |
| 227 | }else{ |
| 228 | srcid = 0; |
| 229 | pXfer->nFileRcvd++; |
| 230 | } |
| 231 | rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid, szC, 0); |
| 232 | remote_has(rid); |
| 233 | blob_reset(&content); |
| 234 | } |
| 235 | |
| 236 | /* |
| @@ -617,11 +617,11 @@ | |
| 617 | nRow++; |
| 618 | if( nRow>=800 && nUncl>nRow+100 ){ |
| 619 | md5sum_blob(&cluster, &cksum); |
| 620 | blob_appendf(&cluster, "Z %b\n", &cksum); |
| 621 | blob_reset(&cksum); |
| 622 | rid = content_put(&cluster); |
| 623 | blob_reset(&cluster); |
| 624 | nUncl -= nRow; |
| 625 | nRow = 0; |
| 626 | blob_appendf(&deleteWhere, ",%d", rid); |
| 627 | } |
| @@ -634,11 +634,11 @@ | |
| 634 | blob_reset(&deleteWhere); |
| 635 | if( nRow>0 ){ |
| 636 | md5sum_blob(&cluster, &cksum); |
| 637 | blob_appendf(&cluster, "Z %b\n", &cksum); |
| 638 | blob_reset(&cksum); |
| 639 | content_put(&cluster); |
| 640 | blob_reset(&cluster); |
| 641 | } |
| 642 | } |
| 643 | } |
| 644 | |
| @@ -1368,11 +1368,11 @@ | |
| 1368 | ){ |
| 1369 | int rid = rid_from_uuid(&xfer.aToken[1], 0); |
| 1370 | if( rid>0 ){ |
| 1371 | content_make_public(rid); |
| 1372 | }else if( pullFlag || cloneFlag ){ |
| 1373 | rid = content_new(blob_str(&xfer.aToken[1]), 0); |
| 1374 | if( rid ) newPhantom = 1; |
| 1375 | } |
| 1376 | remote_has(rid); |
| 1377 | }else |
| 1378 | |
| 1379 |