Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | 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(). |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
1b4516168d1e979ed743d5982fb59130 |
| User & Date: | drh 2011-02-24 17:11:34.701 |
Context
|
2011-02-24
| ||
| 20:00 | Reuse prepared statements to make clone run must faster on the server side. check-in: 1f41b0421d user: drh tags: trunk | |
| 17:11 | 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(). check-in: 1b4516168d user: drh tags: trunk | |
|
2011-02-22
| ||
| 21:14 | Do not print extraneous text about project-id and admin-user at the end of an incremental import. check-in: 691fccbaf7 user: drh tags: trunk | |
Changes
Changes to src/attach.c.
| ︙ | ︙ | |||
239 240 241 242 243 244 245 |
const char *zComment;
char *zDate;
int rid;
int i, n;
db_begin_transaction();
blob_init(&content, aContent, szContent);
| | | | 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
const char *zComment;
char *zDate;
int rid;
int i, n;
db_begin_transaction();
blob_init(&content, aContent, szContent);
rid = content_put(&content);
zUUID = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
blob_zero(&manifest);
for(i=n=0; zName[i]; i++){
if( zName[i]=='/' || zName[i]=='\\' ) n = i;
}
zName += n;
if( zName[0]==0 ) zName = "unknown";
blob_appendf(&manifest, "A %F %F %s\n", zName, zTarget, zUUID);
zComment = PD("comment", "");
while( fossil_isspace(zComment[0]) ) zComment++;
n = strlen(zComment);
while( n>0 && fossil_isspace(zComment[n-1]) ){ n--; }
if( n>0 ){
blob_appendf(&manifest, "C %F\n", zComment);
}
zDate = date_in_standard_format("now");
blob_appendf(&manifest, "D %s\n", zDate);
blob_appendf(&manifest, "U %F\n", g.zLogin ? g.zLogin : "nobody");
md5sum_blob(&manifest, &cksum);
blob_appendf(&manifest, "Z %b\n", &cksum);
rid = content_put(&manifest);
manifest_crosslink(rid, &manifest);
assert( blob_is_reset(&manifest) );
db_end_transaction(0);
cgi_redirect(zFrom);
}
style_header("Add Attachment");
@ <h2>Add Attachment To %s(zTargetType)</h2>
|
| ︙ | ︙ | |||
340 341 342 343 344 345 346 |
if( zFile[0]==0 ) zFile = "unknown";
blob_appendf(&manifest, "A %F %F\n", zFile, zTarget);
zDate = date_in_standard_format("now");
blob_appendf(&manifest, "D %s\n", zDate);
blob_appendf(&manifest, "U %F\n", g.zLogin ? g.zLogin : "nobody");
md5sum_blob(&manifest, &cksum);
blob_appendf(&manifest, "Z %b\n", &cksum);
| | | 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
if( zFile[0]==0 ) zFile = "unknown";
blob_appendf(&manifest, "A %F %F\n", zFile, zTarget);
zDate = date_in_standard_format("now");
blob_appendf(&manifest, "D %s\n", zDate);
blob_appendf(&manifest, "U %F\n", g.zLogin ? g.zLogin : "nobody");
md5sum_blob(&manifest, &cksum);
blob_appendf(&manifest, "Z %b\n", &cksum);
rid = content_put(&manifest);
manifest_crosslink(rid, &manifest);
db_end_transaction(0);
cgi_redirect(zFrom);
}
style_header("Delete Attachment");
@ <form action="%s(g.zTop)/attachdelete" method="post"><div>
@ <p>Confirm that you want to delete the attachment named
|
| ︙ | ︙ |
Changes to src/branch.c.
| ︙ | ︙ | |||
134 135 136 137 138 139 140 |
prompt_user("unable to sign manifest. continue (y/N)? ", &ans);
if( blob_str(&ans)[0]!='y' ){
db_end_transaction(1);
fossil_exit(1);
}
}
| | | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
prompt_user("unable to sign manifest. continue (y/N)? ", &ans);
if( blob_str(&ans)[0]!='y' ){
db_end_transaction(1);
fossil_exit(1);
}
}
brid = content_put(&branch);
if( brid==0 ){
fossil_panic("trouble committing manifest: %s", g.zErrMsg);
}
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", brid);
if( manifest_crosslink(brid, &branch)==0 ){
fossil_panic("unable to install new manifest");
}
|
| ︙ | ︙ |
Changes to src/checkin.c.
| ︙ | ︙ | |||
992 993 994 995 996 997 998 |
id = db_column_int(&q, 0);
zFullname = db_column_text(&q, 1);
rid = db_column_int(&q, 2);
blob_zero(&content);
blob_read_from_file(&content, zFullname);
| | | 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 |
id = db_column_int(&q, 0);
zFullname = db_column_text(&q, 1);
rid = db_column_int(&q, 2);
blob_zero(&content);
blob_read_from_file(&content, zFullname);
nrid = content_put(&content);
blob_reset(&content);
if( rid>0 ){
content_deltify(rid, nrid, 0);
}
db_multi_exec("UPDATE vfile SET mrid=%d, rid=%d WHERE id=%d", nrid,nrid,id);
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
}
|
| ︙ | ︙ | |||
1084 1085 1086 1087 1088 1089 1090 |
if( outputManifest ){
zManifestFile = mprintf("%smanifest", g.zLocalRoot);
blob_write_to_file(&manifest, zManifestFile);
blob_reset(&manifest);
blob_read_from_file(&manifest, zManifestFile);
free(zManifestFile);
}
| | | 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 |
if( outputManifest ){
zManifestFile = mprintf("%smanifest", g.zLocalRoot);
blob_write_to_file(&manifest, zManifestFile);
blob_reset(&manifest);
blob_read_from_file(&manifest, zManifestFile);
free(zManifestFile);
}
nvid = content_put(&manifest);
if( nvid==0 ){
fossil_panic("trouble committing manifest: %s", g.zErrMsg);
}
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid);
manifest_crosslink(nvid, &manifest);
assert( blob_is_reset(&manifest) );
content_deltify(vid, nvid, 0);
|
| ︙ | ︙ |
Changes to src/content.c.
| ︙ | ︙ | |||
428 429 430 431 432 433 434 | } /* ** Write content into the database. Return the record ID. If the ** content is already in the database, just return the record ID. ** ** If srcId is specified, then pBlob is delta content from | | > > | > > > > > > | 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 |
}
/*
** Write content into the database. Return the record ID. If the
** content is already in the database, just return the record ID.
**
** If srcId is specified, then pBlob is delta content from
** the srcId record. srcId might be a phantom.
**
** pBlob is normally uncompressed text. But if nBlob>0 then the
** pBlob value has already been compressed and nBlob is its uncompressed
** size. If nBlob>0 then zUuid must be valid.
**
** zUuid is the UUID of the artifact, if it is specified. When srcId is
** specified then zUuid must always be specified. If srcId is zero,
** and zUuid is zero then the correct zUuid is computed from pBlob.
**
** If the record already exists but is a phantom, the pBlob content
** is inserted and the phatom becomes a real record.
**
** The original content of pBlob is not disturbed. The caller continues
** to be responsible for pBlob. This routine does *not* take over
** responsiblity for freeing pBlob.
*/
int content_put_ex(
Blob *pBlob, /* Content to add to the repository */
const char *zUuid, /* SHA1 hash of reconstructed pBlob */
int srcId, /* pBlob is a delta from this entry */
int nBlob, /* pBlob is compressed. Original size is this */
int isPrivate /* The content should be marked private */
){
int size;
int rid;
Stmt s1;
Blob cmpr;
Blob hash;
int markAsUnclustered = 0;
int isDephantomize = 0;
|
| ︙ | ︙ | |||
533 534 535 536 537 538 539 |
);
db_bind_blob(&s1, ":data", &cmpr);
db_exec(&s1);
rid = db_last_insert_rowid();
if( !pBlob ){
db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
}
| | | 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 |
);
db_bind_blob(&s1, ":data", &cmpr);
db_exec(&s1);
rid = db_last_insert_rowid();
if( !pBlob ){
db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
}
if( g.markPrivate || isPrivate ){
db_multi_exec("INSERT INTO private VALUES(%d)", rid);
markAsUnclustered = 0;
}
}
if( nBlob==0 ) blob_reset(&cmpr);
/* If the srcId is specified, then the data we just added is
|
| ︙ | ︙ | |||
571 572 573 574 575 576 577 578 579 580 581 | blob_reset(&hash); /* Make arrangements to verify that the data can be recovered ** before we commit */ verify_before_commit(rid); return rid; } /* ** Create a new phantom with the given UUID and return its artifact ID. */ | > > > > > > > > > > > > > > > > | | 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 |
blob_reset(&hash);
/* Make arrangements to verify that the data can be recovered
** before we commit */
verify_before_commit(rid);
return rid;
}
/*
** This is the simple common case for inserting content into the
** repository. pBlob is the content to be inserted.
**
** pBlob is uncompressed and is not deltaed. It is exactly the content
** to be inserted.
**
** The original content of pBlob is not disturbed. The caller continues
** to be responsible for pBlob. This routine does *not* take over
** responsiblity for freeing pBlob.
*/
int content_put(Blob *pBlob){
return content_put_ex(pBlob, 0, 0, 0, 0);
}
/*
** Create a new phantom with the given UUID and return its artifact ID.
*/
int content_new(const char *zUuid, int isPrivate){
int rid;
static Stmt s1, s2, s3;
assert( g.repositoryOpen );
db_begin_transaction();
if( uuid_is_shunned(zUuid) ){
db_end_transaction(0);
|
| ︙ | ︙ | |||
597 598 599 600 601 602 603 |
db_exec(&s1);
rid = db_last_insert_rowid();
db_static_prepare(&s2,
"INSERT INTO phantom VALUES(:rid)"
);
db_bind_int(&s2, ":rid", rid);
db_exec(&s2);
| | | 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 |
db_exec(&s1);
rid = db_last_insert_rowid();
db_static_prepare(&s2,
"INSERT INTO phantom VALUES(:rid)"
);
db_bind_int(&s2, ":rid", rid);
db_exec(&s2);
if( g.markPrivate || isPrivate ){
db_multi_exec("INSERT INTO private VALUES(%d)", rid);
}else{
db_static_prepare(&s3,
"INSERT INTO unclustered VALUES(:rid)"
);
db_bind_int(&s3, ":rid", rid);
db_exec(&s3);
|
| ︙ | ︙ | |||
624 625 626 627 628 629 630 |
void test_content_put_cmd(void){
int rid;
Blob content;
if( g.argc!=3 ) usage("FILENAME");
db_must_be_within_tree();
user_select();
blob_read_from_file(&content, g.argv[2]);
| | | 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 |
void test_content_put_cmd(void){
int rid;
Blob content;
if( g.argc!=3 ) usage("FILENAME");
db_must_be_within_tree();
user_select();
blob_read_from_file(&content, g.argv[2]);
rid = content_put(&content);
printf("inserted as record %d\n", rid);
}
/*
** Make sure the content at rid is the original content and is not a
** delta.
*/
|
| ︙ | ︙ |
Changes to src/db.c.
| ︙ | ︙ | |||
1116 1117 1118 1119 1120 1121 1122 |
blob_appendf(&manifest, "R %s\n", md5sum_finish(0));
blob_appendf(&manifest, "T *branch * trunk\n");
blob_appendf(&manifest, "T *sym-trunk *\n");
blob_appendf(&manifest, "U %F\n", g.zLogin);
md5sum_blob(&manifest, &hash);
blob_appendf(&manifest, "Z %b\n", &hash);
blob_reset(&hash);
| | | 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 |
blob_appendf(&manifest, "R %s\n", md5sum_finish(0));
blob_appendf(&manifest, "T *branch * trunk\n");
blob_appendf(&manifest, "T *sym-trunk *\n");
blob_appendf(&manifest, "U %F\n", g.zLogin);
md5sum_blob(&manifest, &hash);
blob_appendf(&manifest, "Z %b\n", &hash);
blob_reset(&hash);
rid = content_put(&manifest);
manifest_crosslink(rid, &manifest);
}
}
/*
** COMMAND: new
** COMMAND: init
|
| ︙ | ︙ |
Changes to src/event.c.
| ︙ | ︙ | |||
341 342 343 344 345 346 347 |
if( g.zLogin ){
blob_appendf(&event, "U %F\n", g.zLogin);
}
blob_appendf(&event, "W %d\n%s\n", strlen(zBody), zBody);
md5sum_blob(&event, &cksum);
blob_appendf(&event, "Z %b\n", &cksum);
blob_reset(&cksum);
| | | 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
if( g.zLogin ){
blob_appendf(&event, "U %F\n", g.zLogin);
}
blob_appendf(&event, "W %d\n%s\n", strlen(zBody), zBody);
md5sum_blob(&event, &cksum);
blob_appendf(&event, "Z %b\n", &cksum);
blob_reset(&cksum);
nrid = content_put(&event);
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
manifest_crosslink(nrid, &event);
assert( blob_is_reset(&event) );
content_deltify(rid, nrid, 0);
db_end_transaction(0);
cgi_redirectf("event?name=%T", zEventId);
}
|
| ︙ | ︙ |
Changes to src/info.c.
| ︙ | ︙ | |||
1650 1651 1652 1653 1654 1655 1656 |
int nrid;
Blob cksum;
blob_appendf(&ctrl, "U %F\n", g.zLogin);
md5sum_blob(&ctrl, &cksum);
blob_appendf(&ctrl, "Z %b\n", &cksum);
db_begin_transaction();
g.markPrivate = content_is_private(rid);
| | | 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 |
int nrid;
Blob cksum;
blob_appendf(&ctrl, "U %F\n", g.zLogin);
md5sum_blob(&ctrl, &cksum);
blob_appendf(&ctrl, "Z %b\n", &cksum);
db_begin_transaction();
g.markPrivate = content_is_private(rid);
nrid = content_put(&ctrl);
manifest_crosslink(nrid, &ctrl);
assert( blob_is_reset(&ctrl) );
db_end_transaction(0);
}
cgi_redirectf("ci?name=%s", zUuid);
}
blob_zero(&comment);
|
| ︙ | ︙ |
Changes to src/rebuild.c.
| ︙ | ︙ | |||
594 595 596 597 598 599 600 |
}
blob_init(&path, 0, 0);
blob_appendf(&path, "%s", zSubpath);
if( blob_read_from_file(&aContent, blob_str(&path))==-1 ){
fossil_panic("some unknown error occurred while reading \"%s\"",
blob_str(&path));
}
| | | 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 |
}
blob_init(&path, 0, 0);
blob_appendf(&path, "%s", zSubpath);
if( blob_read_from_file(&aContent, blob_str(&path))==-1 ){
fossil_panic("some unknown error occurred while reading \"%s\"",
blob_str(&path));
}
content_put(&aContent);
blob_reset(&path);
blob_reset(&aContent);
free(zSubpath);
printf("\r%d", ++nFileRead);
fflush(stdout);
}
closedir(d);
|
| ︙ | ︙ |
Changes to src/tag.c.
| ︙ | ︙ | |||
307 308 309 310 311 312 313 |
blob_appendf(&ctrl, " %F\n", zValue);
}else{
blob_appendf(&ctrl, "\n");
}
blob_appendf(&ctrl, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin);
md5sum_blob(&ctrl, &cksum);
blob_appendf(&ctrl, "Z %b\n", &cksum);
| | | 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
blob_appendf(&ctrl, " %F\n", zValue);
}else{
blob_appendf(&ctrl, "\n");
}
blob_appendf(&ctrl, "U %F\n", zUserOvrd ? zUserOvrd : g.zLogin);
md5sum_blob(&ctrl, &cksum);
blob_appendf(&ctrl, "Z %b\n", &cksum);
nrid = content_put(&ctrl);
manifest_crosslink(nrid, &ctrl);
assert( blob_is_reset(&ctrl) );
}
/*
** COMMAND: tag
** Usage: %fossil tag SUBCOMMAND ...
|
| ︙ | ︙ |
Changes to src/tkt.c.
| ︙ | ︙ | |||
477 478 479 480 481 482 483 |
@ <hr /></font>
return TH_OK;
}else if( g.thTrace ){
Th_Trace("submit_ticket {\n<blockquote><pre>\n%h\n</pre></blockquote>\n"
"}<br />\n",
blob_str(&tktchng));
}else{
| | | 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
@ <hr /></font>
return TH_OK;
}else if( g.thTrace ){
Th_Trace("submit_ticket {\n<blockquote><pre>\n%h\n</pre></blockquote>\n"
"}<br />\n",
blob_str(&tktchng));
}else{
rid = content_put(&tktchng);
if( rid==0 ){
fossil_panic("trouble committing ticket: %s", g.zErrMsg);
}
manifest_crosslink_begin();
manifest_crosslink(rid, &tktchng);
assert( blob_is_reset(&tktchng) );
manifest_crosslink_end();
|
| ︙ | ︙ | |||
1054 1055 1056 1057 1058 1059 1060 |
}
}
}
blob_appendf(&tktchng, "K %s\n", zTktUuid);
blob_appendf(&tktchng, "U %F\n", g.zLogin);
md5sum_blob(&tktchng, &cksum);
blob_appendf(&tktchng, "Z %b\n", &cksum);
| | | 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 |
}
}
}
blob_appendf(&tktchng, "K %s\n", zTktUuid);
blob_appendf(&tktchng, "U %F\n", g.zLogin);
md5sum_blob(&tktchng, &cksum);
blob_appendf(&tktchng, "Z %b\n", &cksum);
rid = content_put(&tktchng);
if( rid==0 ){
fossil_panic("trouble committing ticket: %s", g.zErrMsg);
}
manifest_crosslink_begin();
manifest_crosslink(rid, &tktchng);
manifest_crosslink_end();
assert( blob_is_reset(&tktchng) );
printf("ticket %s succeeded for UID %s\n",
(eCmd==set?"set":"add"),zTktUuid);
}
}
}
}
|
Changes to src/vfile.c.
| ︙ | ︙ | |||
48 49 50 51 52 53 54 | /* ** Given a UUID, return the corresponding record ID. If the UUID ** does not exist, then return 0. ** ** For this routine, the UUID must be exact. For a match against ** user input with mixed case, use resolve_uuid(). ** | | | > | | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
/*
** Given a UUID, return the corresponding record ID. If the UUID
** does not exist, then return 0.
**
** For this routine, the UUID must be exact. For a match against
** user input with mixed case, use resolve_uuid().
**
** If the UUID is not found and phantomize is 1 or 2, then attempt to
** create a phantom record. A private phantom is created for 2 and
** a public phantom is created for 1.
*/
int uuid_to_rid(const char *zUuid, int phantomize){
int rid, sz;
char z[UUID_SIZE+1];
sz = strlen(zUuid);
if( sz!=UUID_SIZE || !validate16(zUuid, sz) ){
return 0;
}
memcpy(z, zUuid, UUID_SIZE+1);
canonical16(z, sz);
rid = fast_uuid_to_rid(z);
if( rid==0 && phantomize ){
rid = content_new(zUuid, phantomize-1);
}
return rid;
}
/*
** Build a catalog of all files in a checkin.
*/
|
| ︙ | ︙ |
Changes to src/wiki.c.
| ︙ | ︙ | |||
319 320 321 322 323 324 325 |
if( g.zLogin ){
blob_appendf(&wiki, "U %F\n", g.zLogin);
}
blob_appendf(&wiki, "W %d\n%s\n", strlen(zBody), zBody);
md5sum_blob(&wiki, &cksum);
blob_appendf(&wiki, "Z %b\n", &cksum);
blob_reset(&cksum);
| | | 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
if( g.zLogin ){
blob_appendf(&wiki, "U %F\n", g.zLogin);
}
blob_appendf(&wiki, "W %d\n%s\n", strlen(zBody), zBody);
md5sum_blob(&wiki, &cksum);
blob_appendf(&wiki, "Z %b\n", &cksum);
blob_reset(&cksum);
nrid = content_put(&wiki);
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
manifest_crosslink(nrid, &wiki);
assert( blob_is_reset(&wiki) );
content_deltify(rid, nrid, 0);
}
db_end_transaction(0);
cgi_redirectf("wiki?name=%T", zPageName);
|
| ︙ | ︙ | |||
491 492 493 494 495 496 497 |
blob_appendf(&wiki, "U %F\n", g.zLogin);
}
appendRemark(&body);
blob_appendf(&wiki, "W %d\n%s\n", blob_size(&body), blob_str(&body));
md5sum_blob(&wiki, &cksum);
blob_appendf(&wiki, "Z %b\n", &cksum);
blob_reset(&cksum);
| | | 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
blob_appendf(&wiki, "U %F\n", g.zLogin);
}
appendRemark(&body);
blob_appendf(&wiki, "W %d\n%s\n", blob_size(&body), blob_str(&body));
md5sum_blob(&wiki, &cksum);
blob_appendf(&wiki, "Z %b\n", &cksum);
blob_reset(&cksum);
nrid = content_put(&wiki);
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
manifest_crosslink(nrid, &wiki);
assert( blob_is_reset(&wiki) );
content_deltify(rid, nrid, 0);
db_end_transaction(0);
}
cgi_redirectf("wiki?name=%T", zPageName);
|
| ︙ | ︙ | |||
815 816 817 818 819 820 821 |
}
blob_appendf( &wiki, "W %d\n%s\n", blob_size(pContent),
blob_str(pContent) );
md5sum_blob(&wiki, &cksum);
blob_appendf(&wiki, "Z %b\n", &cksum);
blob_reset(&cksum);
db_begin_transaction();
| | | 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 |
}
blob_appendf( &wiki, "W %d\n%s\n", blob_size(pContent),
blob_str(pContent) );
md5sum_blob(&wiki, &cksum);
blob_appendf(&wiki, "Z %b\n", &cksum);
blob_reset(&cksum);
db_begin_transaction();
nrid = content_put( &wiki);
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nrid);
manifest_crosslink(nrid,&wiki);
assert( blob_is_reset(&wiki) );
content_deltify(rid,nrid,0);
db_end_transaction(0);
autosync(AUTOSYNC_PUSH);
return 1;
|
| ︙ | ︙ |
Changes to src/xfer.c.
| ︙ | ︙ | |||
60 61 62 63 64 65 66 |
if( db_step(&q)==SQLITE_ROW ){
rid = db_column_int(&q, 0);
}else{
rid = 0;
}
db_reset(&q);
if( rid==0 && phantomize ){
| | | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
if( db_step(&q)==SQLITE_ROW ){
rid = db_column_int(&q, 0);
}else{
rid = 0;
}
db_reset(&q);
if( rid==0 && phantomize ){
rid = content_new(blob_str(pUuid), 0);
}
return rid;
}
/*
** Remember that the other side of the connection already has a copy
** of the file rid.
|
| ︙ | ︙ | |||
130 131 132 133 134 135 136 |
if( pXfer->nToken==4 ){
srcid = rid_from_uuid(&pXfer->aToken[2], 1);
pXfer->nDeltaRcvd++;
}else{
srcid = 0;
pXfer->nFileRcvd++;
}
| | | | | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
if( pXfer->nToken==4 ){
srcid = rid_from_uuid(&pXfer->aToken[2], 1);
pXfer->nDeltaRcvd++;
}else{
srcid = 0;
pXfer->nFileRcvd++;
}
rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid, 0, 0);
remote_has(rid);
blob_reset(&content);
return;
}
if( pXfer->nToken==4 ){
Blob src, next;
srcid = rid_from_uuid(&pXfer->aToken[2], 1);
if( content_get(srcid, &src)==0 ){
rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid, 0, 0);
pXfer->nDanglingFile++;
db_multi_exec("DELETE FROM phantom WHERE rid=%d", rid);
content_make_public(rid);
return;
}
pXfer->nDeltaRcvd++;
blob_delta_apply(&src, &content, &next);
blob_reset(&src);
blob_reset(&content);
content = next;
}else{
pXfer->nFileRcvd++;
}
sha1sum_blob(&content, &hash);
if( !blob_eq_str(&pXfer->aToken[1], blob_str(&hash), -1) ){
blob_appendf(&pXfer->err, "content does not match sha1 hash");
}
rid = content_put_ex(&content, blob_str(&hash), 0, 0, 0);
blob_reset(&hash);
if( rid==0 ){
blob_appendf(&pXfer->err, "%s", g.zErrMsg);
blob_reset(&content);
}else{
content_make_public(rid);
manifest_crosslink(rid, &content);
|
| ︙ | ︙ | |||
224 225 226 227 228 229 230 |
if( pXfer->nToken==5 ){
srcid = rid_from_uuid(&pXfer->aToken[2], 1);
pXfer->nDeltaRcvd++;
}else{
srcid = 0;
pXfer->nFileRcvd++;
}
| | | 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
if( pXfer->nToken==5 ){
srcid = rid_from_uuid(&pXfer->aToken[2], 1);
pXfer->nDeltaRcvd++;
}else{
srcid = 0;
pXfer->nFileRcvd++;
}
rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid, szC, 0);
remote_has(rid);
blob_reset(&content);
}
/*
** Try to send a file as a delta against its parent.
** If successful, return the number of bytes in the delta.
|
| ︙ | ︙ | |||
615 616 617 618 619 620 621 |
while( db_step(&q)==SQLITE_ROW ){
blob_appendf(&cluster, "M %s\n", db_column_text(&q, 0));
nRow++;
if( nRow>=800 && nUncl>nRow+100 ){
md5sum_blob(&cluster, &cksum);
blob_appendf(&cluster, "Z %b\n", &cksum);
blob_reset(&cksum);
| | | | 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
while( db_step(&q)==SQLITE_ROW ){
blob_appendf(&cluster, "M %s\n", db_column_text(&q, 0));
nRow++;
if( nRow>=800 && nUncl>nRow+100 ){
md5sum_blob(&cluster, &cksum);
blob_appendf(&cluster, "Z %b\n", &cksum);
blob_reset(&cksum);
rid = content_put(&cluster);
blob_reset(&cluster);
nUncl -= nRow;
nRow = 0;
blob_appendf(&deleteWhere, ",%d", rid);
}
}
db_finalize(&q);
db_multi_exec(
"DELETE FROM unclustered WHERE rid NOT IN (0 %s)",
blob_str(&deleteWhere)
);
blob_reset(&deleteWhere);
if( nRow>0 ){
md5sum_blob(&cluster, &cksum);
blob_appendf(&cluster, "Z %b\n", &cksum);
blob_reset(&cksum);
content_put(&cluster);
blob_reset(&cluster);
}
}
}
/*
** Send an igot message for every entry in unclustered table.
|
| ︙ | ︙ | |||
1366 1367 1368 1369 1370 1371 1372 |
&& blob_eq(&xfer.aToken[0], "igot")
&& blob_is_uuid(&xfer.aToken[1])
){
int rid = rid_from_uuid(&xfer.aToken[1], 0);
if( rid>0 ){
content_make_public(rid);
}else if( pullFlag || cloneFlag ){
| | | 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 |
&& blob_eq(&xfer.aToken[0], "igot")
&& blob_is_uuid(&xfer.aToken[1])
){
int rid = rid_from_uuid(&xfer.aToken[1], 0);
if( rid>0 ){
content_make_public(rid);
}else if( pullFlag || cloneFlag ){
rid = content_new(blob_str(&xfer.aToken[1]), 0);
if( rid ) newPhantom = 1;
}
remote_has(rid);
}else
/* push SERVERCODE PRODUCTCODE
|
| ︙ | ︙ |