Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add the db_fingerprint() interface for computing a repository fingerprint. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | repo-fingerprint |
Files: | files | file ages | folders |
SHA3-256: |
f5043617c0f725a2c88084f923def46e |
User & Date: | drh 2019-01-10 19:54:25.729 |
Context
2019-01-10
| ||
21:07 | Store "fingerprint" and "checkout-hash" in the VVAR table whenever the working checkout changes. ... (check-in: e07139a0 user: drh tags: repo-fingerprint) | |
19:54 | Add the db_fingerprint() interface for computing a repository fingerprint. ... (check-in: f5043617 user: drh tags: repo-fingerprint) | |
18:25 | Fix the remote_repo_info() function to avoid resource leaks and to suppress unhelpful error and warning messages. ... (check-in: 1e3cfc1e user: drh tags: trunk) | |
Changes
Changes to src/db.c.
︙ | ︙ | |||
3702 3703 3704 3705 3706 3707 3708 | */ void test_database_name_cmd(void){ db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); fossil_print("Repository database: %s\n", g.zRepositoryName); fossil_print("Local database: %s\n", g.zLocalDbName); fossil_print("Config database: %s\n", g.zConfigDbName); } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 | */ void test_database_name_cmd(void){ db_find_and_open_repository(OPEN_ANY_SCHEMA, 0); fossil_print("Repository database: %s\n", g.zRepositoryName); fossil_print("Local database: %s\n", g.zLocalDbName); fossil_print("Config database: %s\n", g.zConfigDbName); } /* ** Compute a "fingerprint" on the repository. A fingerprint is used ** to verify that that the repository has not been replaced by a clone ** of the same repository. More precisely, a fingerprint are used to ** verify that the mapping between SHA3 hashes and RID values is unchanged. ** ** The checkout database ("localdb") stores RID values. When associating ** a checkout database against a repository database, it is useful to verify ** the fingerprint so that we know tha the RID values in the checkout ** database still correspond to the correct entries in the BLOB table of ** the repository. ** ** The fingerprint is based on the RCVFROM table. When constructing a ** new fingerprint, use the most recent RCVFROM entry. (Set rcvid==0 to ** accomplish this.) When verifying an old fingerprint, use the same ** RCVFROM entry that generated the fingerprint in the first place. ** ** The fingerprint consists of the rcvid, a "/", and the MD5 checksum of ** the remaining fields of the RCVFROM table entry. */ char *db_fingerprint(int rcvid){ char *z = 0; Blob sql = BLOB_INITIALIZER; Stmt q; blob_append_sql(&sql, "SELECT rcvid, quote(uid), quote(mtime), quote(nonce), quote(ipaddr)" " FROM rcvfrom" ); if( rcvid<=0 ){ blob_append_sql(&sql, " ORDER BY rcvid DESC LIMIT 1"); }else{ blob_append_sql(&sql, " WHERE rcvid=%d", rcvid); } db_prepare_blob(&q, &sql); blob_reset(&sql); if( db_step(&q)==SQLITE_ROW ){ int i; md5sum_init(); for(i=1; i<=4; i++){ md5sum_step_text(db_column_text(&q,i),-1); } z = mprintf("%d/%s",db_column_int(&q,0),md5sum_finish(0)); } db_finalize(&q); return z; } /* ** COMMAND: test-fingerprint ** ** Usage: %fossil test-fingerprint ?RCVID? ** ** Display the repository fingerprint. */ void test_fingerprint(void){ int rcvid = 0; db_find_and_open_repository(OPEN_ANY_SCHEMA,0); if( g.argc==3 ){ rcvid = atoi(g.argv[2]); }else if( g.argc!=2 ){ fossil_fatal("wrong number of arguments"); } fossil_print("%z\n", db_fingerprint(rcvid)); } |