Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add code to generate "config" card for transmitting configuration information using the new format. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | config-sync |
| Files: | files | file ages | folders |
| SHA1: |
9522964b24384ddb0ce8a0d44315d9ce |
| User & Date: | drh 2011-04-26 15:39:37.181 |
Context
|
2011-04-26
| ||
| 18:36 | Update the "configure" command so that the "import", "export", and "merge" subcommands use the new config format. ... (check-in: 4291183882 user: drh tags: config-sync) | |
| 15:39 | Add code to generate "config" card for transmitting configuration information using the new format. ... (check-in: 9522964b24 user: drh tags: config-sync) | |
| 01:33 | Schema changes that an mtime field to all configuration tables and make "title" a unique field on the reportfmt table. Only lightly tested. ... (check-in: 2b4b3303b6 user: drh tags: config-sync) | |
Changes
Changes to src/configure.c.
| ︙ | ︙ | |||
478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
"REPLACE INTO config(name,value) VALUES(%Q,%Q)",
zName, blob_str(pContent)
);
}
}
}
/*
** After receiving configuration data, call this routine to transfer
** the results into the main database.
*/
void configure_finalize_receive(void){
static const char zSQL[] =
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 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 614 615 616 617 |
"REPLACE INTO config(name,value) VALUES(%Q,%Q)",
zName, blob_str(pContent)
);
}
}
}
/*
** Send "config" cards using the new format for all elements of a group
** that have recently changed.
**
** Output goes into pOut. The groupMask identifies the group(s) to be sent.
** Send only entries whose timestamp is later than or equal to iStart.
*/
void configure_send_group(
Blob *pOut, /* Write output here */
int groupMask, /* Mask of groups to be send */
sqlite3_int64 iStart /* Only write values changed since this time */
){
Stmt q;
Blob rec;
int ii;
blob_zero(&rec);
if( groupMask & CONFIGSET_SHUN ){
db_prepare(&q, "SELECT mtime, quote(uuid), quote(scom) FROM shun"
" WHERE mtime>=%lld", iStart);
while( db_step(&q)==SQLITE_ROW ){
blob_appendf(&rec,"%s %s scom %s\n",
db_column_text(&q, 0),
db_column_text(&q, 1),
db_column_text(&q, 2)
);
blob_appendf(pOut, "config /shun %d\n%s",
blob_size(&rec), blob_str(&rec));
blob_reset(&rec);
}
db_finalize(&q);
}
if( groupMask & CONFIGSET_USER ){
db_prepare(&q, "SELECT mtime, quote(login), quote(pw), quote(cap),"
" quote(info), quote(photo) FROM user"
" WHERE mtime>=%lld", iStart);
while( db_step(&q)==SQLITE_ROW ){
blob_appendf(&rec,"%s %s pw %s cap %s info %s photo %s\n",
db_column_text(&q, 0),
db_column_text(&q, 1),
db_column_text(&q, 2),
db_column_text(&q, 3),
db_column_text(&q, 4),
db_column_text(&q, 5)
);
blob_appendf(pOut, "config /user %d\n%s",
blob_size(&rec), blob_str(&rec));
blob_reset(&rec);
}
db_finalize(&q);
}
if( groupMask & CONFIGSET_TKT ){
db_prepare(&q, "SELECT mtime, quote(title), quote(owner), quote(cols),"
" quote(sqlcode) FROM reportfmt"
" WHERE mtime>=%lld", iStart);
while( db_step(&q)==SQLITE_ROW ){
blob_appendf(&rec,"%s %s owner %s cols %s sqlcode %s\n",
db_column_text(&q, 0),
db_column_text(&q, 1),
db_column_text(&q, 2),
db_column_text(&q, 3),
db_column_text(&q, 4)
);
blob_appendf(pOut, "config /reportfmt %d\n%s",
blob_size(&rec), blob_str(&rec));
blob_reset(&rec);
}
db_finalize(&q);
}
if( groupMask & CONFIGSET_ADDR ){
db_prepare(&q, "SELECT mtime, quote(hash), quote(content) FROM concealed"
" WHERE mtime>=%lld", iStart);
while( db_step(&q)==SQLITE_ROW ){
blob_appendf(&rec,"%s %s content %s\n",
db_column_text(&q, 0),
db_column_text(&q, 1),
db_column_text(&q, 2)
);
blob_appendf(pOut, "config /concealed %d\n%s",
blob_size(&rec), blob_str(&rec));
blob_reset(&rec);
}
db_finalize(&q);
}
db_prepare(&q, "SELECT mtime, quote(name), quote(value) FROM config"
" WHERE name=:name AND mtime>=%lld", iStart);
for(ii=0; ii<count(aConfig); ii++){
if( (aConfig[ii].groupMask & groupMask)!=0 && aConfig[ii].zName[0]!='@' ){
db_bind_text(&q, ":name", aConfig[ii].zName);
while( db_step(&q)==SQLITE_ROW ){
blob_appendf(&rec,"%s %s value %s\n",
db_column_text(&q, 0),
db_column_text(&q, 1),
db_column_text(&q, 2)
);
blob_appendf(pOut, "config /config %d\n%s",
blob_size(&rec), blob_str(&rec));
blob_reset(&rec);
}
db_reset(&q);
}
}
db_finalize(&q);
}
/*
** COMMAND: test-config-send
**
** Usage: %fossil test-config-send GROUP START
*/
void test_config_send(void){
Blob out;
sqlite3_int64 iStart;
int i;
blob_zero(&out);
db_find_and_open_repository(0,0);
if( g.argc!=4 ) usage("GROUP START");
iStart = db_int64(0, "SELECT strftime('%%s',%Q)", g.argv[3]);
for(i=0; i<count(aGroupName); i++){
if( fossil_strcmp(g.argv[2], aGroupName[i].zName)==0 ){
configure_send_group(&out, aGroupName[i].groupMask, iStart);
printf("%s", blob_str(&out));
blob_reset(&out);
}
}
}
/*
** After receiving configuration data, call this routine to transfer
** the results into the main database.
*/
void configure_finalize_receive(void){
static const char zSQL[] =
|
| ︙ | ︙ |
Changes to src/xfer.c.
| ︙ | ︙ | |||
736 737 738 739 740 741 742 |
while( db_step(&q)==SQLITE_ROW ){
blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0));
}
db_finalize(&q);
}
/*
| | | 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 |
while( db_step(&q)==SQLITE_ROW ){
blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0));
}
db_finalize(&q);
}
/*
** Send a single old-style config card for configuration item zName
*/
static void send_config_card(Xfer *pXfer, const char *zName){
if( zName[0]!='@' ){
Blob val;
blob_zero(&val);
db_blob(&val, "SELECT value FROM config WHERE name=%Q", zName);
if( blob_size(&val)>0 ){
|
| ︙ | ︙ | |||
758 759 760 761 762 763 764 |
blob_zero(&content);
configure_render_special_name(zName, &content);
blob_appendf(pXfer->pOut, "config %s %d\n%s\n", zName,
blob_size(&content), blob_str(&content));
blob_reset(&content);
}
}
| < | 758 759 760 761 762 763 764 765 766 767 768 769 770 771 |
blob_zero(&content);
configure_render_special_name(zName, &content);
blob_appendf(pXfer->pOut, "config %s %d\n%s\n", zName,
blob_size(&content), blob_str(&content));
blob_reset(&content);
}
}
/*
** Called when there is an attempt to transfer private content to and
** from a server without authorization.
*/
static void server_private_xfer_not_authorized(void){
@ error not\sauthorized\sto\ssync\sprivate\scontent
|
| ︙ | ︙ |