diff --git a/commandline.c b/commandline.c index e6e669de..701bb694 100644 --- a/commandline.c +++ b/commandline.c @@ -1438,6 +1438,10 @@ int app_rhizome_add_file(const struct cli_parsed *parsed, struct cli_context *co cli_field_name(context, ".author", ":"); cli_put_string(context, alloca_tohex_sid_t(mout->author), "\n"); } + cli_field_name(context, ".rowid", ":"); + cli_put_long(context, m->rowid, "\n"); + cli_field_name(context, ".inserttime", ":"); + cli_put_long(context, m->inserttime, "\n"); if (mout->has_bundle_key) { cli_field_name(context, "BK", ":"); cli_put_string(context, alloca_tohex_rhizome_bk_t(mout->bundle_key), "\n"); @@ -1727,6 +1731,19 @@ int app_rhizome_extract(const struct cli_parsed *parsed, struct cli_context *con } cli_field_name(context, "manifestid", ":"); cli_put_string(context, alloca_tohex_rhizome_bid_t(bid), "\n"); + cli_field_name(context, "version", ":"); + cli_put_long(context, m->version, "\n"); + if (m->has_date) { + cli_field_name(context, "date", ":"); + cli_put_long(context, m->date, "\n"); + } + cli_field_name(context, "filesize", ":"); + cli_put_long(context, m->filesize, "\n"); + assert(m->filesize != RHIZOME_SIZE_UNSET); + if (m->filesize != 0) { + cli_field_name(context, "filehash", ":"); + cli_put_string(context, alloca_tohex_rhizome_filehash_t(m->filehash), "\n"); + } if (m->haveSecret) { char secret[RHIZOME_BUNDLE_KEY_STRLEN + 1]; rhizome_bytes_to_hex_upper(m->cryptoSignSecret, secret, RHIZOME_BUNDLE_KEY_BYTES); @@ -1738,19 +1755,12 @@ int app_rhizome_extract(const struct cli_parsed *parsed, struct cli_context *con cli_field_name(context, ".author", ":"); cli_put_string(context, alloca_tohex_sid_t(m->author), "\n"); } - cli_field_name(context, "version", ":"); - cli_put_long(context, m->version, "\n"); - cli_field_name(context, "inserttime", ":"); + cli_field_name(context, ".rowid", ":"); + cli_put_long(context, m->rowid, "\n"); + cli_field_name(context, ".inserttime", ":"); cli_put_long(context, m->inserttime, "\n"); cli_field_name(context, ".readonly", ":"); cli_put_long(context, m->haveSecret?0:1, "\n"); - cli_field_name(context, "filesize", ":"); - cli_put_long(context, m->filesize, "\n"); - assert(m->filesize != RHIZOME_SIZE_UNSET); - if (m->filesize != 0) { - cli_field_name(context, "filehash", ":"); - cli_put_string(context, alloca_tohex_rhizome_filehash_t(m->filehash), "\n"); - } } int retfile=0; @@ -1889,7 +1899,7 @@ int app_rhizome_list(const struct cli_parsed *parsed, struct cli_context *contex rhizome_manifest *m = cursor.manifest; assert(m->filesize != RHIZOME_SIZE_UNSET); rhizome_lookup_author(m); - cli_put_long(context, cursor.rowid, ":"); + cli_put_long(context, m->rowid, ":"); cli_put_string(context, m->service, ":"); cli_put_hexvalue(context, m->cryptoSignPublic.binary, sizeof m->cryptoSignPublic.binary, ":"); cli_put_long(context, m->version, ":"); diff --git a/rhizome.h b/rhizome.h index 6ef569f8..8f5c2055 100644 --- a/rhizome.h +++ b/rhizome.h @@ -291,6 +291,12 @@ typedef struct rhizome_manifest sid_t sender; sid_t recipient; + /* Local data, not encapsulated in the bundle. The ROWID of the SQLite + * MANIFESTS table row in which this manifest is stored. Zero if the + * manifest has not been stored yet. + */ + uint64_t rowid; + /* Local data, not encapsulated in the bundle. The system time of the most * recent INSERT or UPDATE of the manifest into the store. Zero if the manifest * has not been stored yet. @@ -342,6 +348,7 @@ typedef struct rhizome_manifest #define rhizome_manifest_set_recipient(m,v) _rhizome_manifest_set_recipient(__WHENCE__,(m),(v)) #define rhizome_manifest_del_recipient(m) _rhizome_manifest_del_recipient(__WHENCE__,(m)) #define rhizome_manifest_set_crypt(m,v) _rhizome_manifest_set_crypt(__WHENCE__,(m),(v)) +#define rhizome_manifest_set_rowid(m,v) _rhizome_manifest_set_rowid(__WHENCE__,(m),(v)) #define rhizome_manifest_set_inserttime(m,v) _rhizome_manifest_set_inserttime(__WHENCE__,(m),(v)) #define rhizome_manifest_set_author(m,v) _rhizome_manifest_set_author(__WHENCE__,(m),(v)) #define rhizome_manifest_del_author(m) _rhizome_manifest_del_author(__WHENCE__,(m)) @@ -364,6 +371,7 @@ void _rhizome_manifest_del_sender(struct __sourceloc, rhizome_manifest *); void _rhizome_manifest_set_recipient(struct __sourceloc, rhizome_manifest *, const sid_t *); void _rhizome_manifest_del_recipient(struct __sourceloc, rhizome_manifest *); void _rhizome_manifest_set_crypt(struct __sourceloc, rhizome_manifest *, enum rhizome_manifest_crypt); +void _rhizome_manifest_set_rowid(struct __sourceloc, rhizome_manifest *, uint64_t); void _rhizome_manifest_set_inserttime(struct __sourceloc, rhizome_manifest *, time_ms_t); void _rhizome_manifest_set_author(struct __sourceloc, rhizome_manifest *, const sid_t *); void _rhizome_manifest_del_author(struct __sourceloc, rhizome_manifest *); @@ -621,7 +629,6 @@ struct rhizome_list_cursor { sid_t sender; sid_t recipient; // Set by calling the next() function. - int64_t rowid; rhizome_manifest *manifest; // Private state. sqlite3_stmt *_statement; diff --git a/rhizome_bundle.c b/rhizome_bundle.c index 59aaebae..3d4b3db2 100644 --- a/rhizome_bundle.c +++ b/rhizome_bundle.c @@ -310,6 +310,11 @@ void _rhizome_manifest_set_crypt(struct __sourceloc __whence, rhizome_manifest * m->payloadEncryption = flag; } +void _rhizome_manifest_set_rowid(struct __sourceloc __whence, rhizome_manifest *m, uint64_t rowid) +{ + m->rowid = rowid; +} + void _rhizome_manifest_set_inserttime(struct __sourceloc __whence, rhizome_manifest *m, time_ms_t time) { m->inserttime = time; diff --git a/rhizome_crypto.c b/rhizome_crypto.c index 1fb9c28b..774d23be 100644 --- a/rhizome_crypto.c +++ b/rhizome_crypto.c @@ -383,11 +383,11 @@ void rhizome_find_bundle_author_and_secret(rhizome_manifest *m) rhizome_manifest_set_author(m, authorSidp); m->authorship = AUTHOR_AUTHENTIC; // if this bundle is already in the database, update the author. - if (m->inserttime) + if (m->rowid) sqlite_exec_void_loglevel(LOG_LEVEL_WARN, - "UPDATE MANIFESTS SET author = ? WHERE id = ?;", + "UPDATE MANIFESTS SET author = ? WHERE rowid = ?;", SID_T, &m->author, - RHIZOME_BID_T, &m->cryptoSignPublic, + INT64, m->rowid, END); RETURNVOID; // bingo } diff --git a/rhizome_database.c b/rhizome_database.c index f4d7941c..bb2b6a0a 100644 --- a/rhizome_database.c +++ b/rhizome_database.c @@ -1343,6 +1343,7 @@ int rhizome_store_bundle(rhizome_manifest *m) goto rollback; sqlite3_finalize(stmt); stmt = NULL; + rhizome_manifest_set_rowid(m, sqlite3_last_insert_rowid(rhizome_db)); rhizome_manifest_set_inserttime(m, now); // if (serverMode) @@ -1486,7 +1487,7 @@ int rhizome_list_next(sqlite_retry_state *retry, struct rhizome_list_cursor *c) int64_t q_version = sqlite3_column_int64(c->_statement, 2); int64_t q_inserttime = sqlite3_column_int64(c->_statement, 3); const char *q_author = (const char *) sqlite3_column_text(c->_statement, 4); - c->rowid = sqlite3_column_int64(c->_statement, 5); + uint64_t q_rowid = sqlite3_column_int64(c->_statement, 5); sid_t *author = NULL; if (q_author) { author = alloca(sizeof *author); @@ -1509,6 +1510,7 @@ int rhizome_list_next(sqlite_retry_state *retry, struct rhizome_list_cursor *c) } if (author) rhizome_manifest_set_author(m, author); + rhizome_manifest_set_rowid(m, q_rowid); rhizome_manifest_set_inserttime(m, q_inserttime); if (c->service && !(m->service && strcasecmp(c->service, m->service) == 0)) continue; @@ -1526,11 +1528,11 @@ int rhizome_list_next(sqlite_retry_state *retry, struct rhizome_list_cursor *c) void rhizome_list_commit(struct rhizome_list_cursor *c) { - assert(c->rowid != 0); - if (c->rowid > c->_rowid_first) - c->_rowid_first = c->rowid; - if (c->_rowid_last == 0 || c->rowid < c->_rowid_last) - c->_rowid_last = c->rowid; + assert(c->manifest->rowid != 0); + if (c->manifest->rowid > c->_rowid_first) + c->_rowid_first = c->manifest->rowid; + if (c->_rowid_last == 0 || c->manifest->rowid < c->_rowid_last) + c->_rowid_last = c->manifest->rowid; } void rhizome_list_release(struct rhizome_list_cursor *c) @@ -1667,6 +1669,7 @@ static int unpack_manifest_row(rhizome_manifest *m, sqlite3_stmt *statement) int64_t q_inserttime = sqlite3_column_int64(statement, 3); const char *q_author = (const char *) sqlite3_column_text(statement, 4); size_t q_blobsize = sqlite3_column_bytes(statement, 1); // must call after sqlite3_column_blob() + uint64_t q_rowid = sqlite3_column_int64(statement, 5); if (rhizome_read_manifest_file(m, q_blob, q_blobsize) == -1) return WHYF("Manifest %s exists but is invalid", q_id); if (q_author) { @@ -1678,6 +1681,7 @@ static int unpack_manifest_row(rhizome_manifest *m, sqlite3_stmt *statement) } if (m->version != q_version) WARNF("Version mismatch, manifest is %"PRId64", database is %"PRId64, m->version, q_version); + rhizome_manifest_set_rowid(m, q_rowid); rhizome_manifest_set_inserttime(m, q_inserttime); return 0; } @@ -1693,7 +1697,7 @@ int rhizome_retrieve_manifest(const rhizome_bid_t *bidp, rhizome_manifest *m) { sqlite_retry_state retry = SQLITE_RETRY_STATE_DEFAULT; sqlite3_stmt *statement = sqlite_prepare_bind(&retry, - "SELECT id, manifest, version, inserttime, author FROM manifests WHERE id = ?", + "SELECT id, manifest, version, inserttime, author, rowid FROM manifests WHERE id = ?", RHIZOME_BID_T, bidp, END); if (!statement) @@ -1723,7 +1727,7 @@ int rhizome_retrieve_manifest_by_prefix(const unsigned char *prefix, unsigned pr like[prefix_strlen] = '%'; like[prefix_strlen + 1] = '\0'; sqlite3_stmt *statement = sqlite_prepare_bind(&retry, - "SELECT id, manifest, version, inserttime, author FROM manifests WHERE id like ?", + "SELECT id, manifest, version, inserttime, author, rowid FROM manifests WHERE id like ?", TEXT, like, END); if (!statement) diff --git a/rhizome_http.c b/rhizome_http.c index 98d3c629..8f26957c 100644 --- a/rhizome_http.c +++ b/rhizome_http.c @@ -406,7 +406,7 @@ static int restful_rhizome_bundlelist_json_content_chunk(sqlite_retry_state *ret assert(m->filesize != RHIZOME_SIZE_UNSET); rhizome_lookup_author(m); strbuf_puts(b, ",\n ["); - strbuf_sprintf(b, "%"PRIu64, r->u.list.cursor.rowid); + strbuf_sprintf(b, "%"PRIu64, m->rowid); strbuf_putc(b, ','); strbuf_json_string(b, m->service); strbuf_putc(b, ','); diff --git a/testdefs_rhizome.sh b/testdefs_rhizome.sh index db06a360..631371cd 100644 --- a/testdefs_rhizome.sh +++ b/testdefs_rhizome.sh @@ -302,6 +302,14 @@ extract_stdout_secret() { extract_stdout_keyvalue "$1" .secret "$rexp_bundlesecret" } +extract_stdout_rowid() { + extract_stdout_keyvalue "$1" .rowid "$rexp_rowid" +} + +extract_stdout_inserttime() { + extract_stdout_keyvalue "$1" .inserttime "$rexp_date" +} + extract_stdout_BK() { extract_stdout_keyvalue "$1" BK "$rexp_bundlekey" } diff --git a/tests/rhizomehttp b/tests/rhizomehttp index d698da9f..a9df4d62 100755 --- a/tests/rhizomehttp +++ b/tests/rhizomehttp @@ -111,6 +111,7 @@ setup_RhizomeList() { extract_stdout_filesize SIZE[$n] extract_stdout_filehash HASH[$n] extract_stdout_date DATE[$n] + extract_stdout_rowid ROWID[$n] done } test_RhizomeList() { @@ -176,6 +177,7 @@ test_RhizomeList() { filesize:${SIZE[$n]}, filehash:\"${HASH[$n]}\", date:${DATE[$n]}, + _id:${ROWID[$n]}, \".fromhere\":1, \".author\":\"$SIDA\", } diff --git a/tests/rhizomeops b/tests/rhizomeops index 62892c2c..0668db07 100755 --- a/tests/rhizomeops +++ b/tests/rhizomeops @@ -208,23 +208,27 @@ setup_ExtractManifestAfterAdd() { setup_rhizome echo "A test file" >file1 executeOk_servald rhizome add file $SIDB1 file1 file1.manifest + extract_stdout_rowid rowid executeOk_servald rhizome list assert_rhizome_list --fromhere=1 --author=$SIDB1 file1 extract_manifest_id manifestid file1.manifest extract_manifest_version version file1.manifest extract_manifest_filehash filehash file1.manifest + extract_manifest_date date file1.manifest } test_ExtractManifestAfterAdd() { executeOk_servald rhizome export manifest $manifestid file1x.manifest tfw_cat --stdout --stderr - assertStdoutLineCount '==' 9 + assertStdoutLineCount '==' 11 local size=$(( $(cat file1 | wc -c) + 0 )) assertStdoutGrep --matches=1 "^service:file$" assertStdoutGrep --matches=1 "^manifestid:$manifestid\$" assertStdoutGrep --matches=1 "^version:$version\$" - assertStdoutGrep --matches=1 "^inserttime:$rexp_date\$" + assertStdoutGrep --matches=1 "^\.rowid:$rowid\$" + assertStdoutGrep --matches=1 "^\.inserttime:$rexp_date\$" assertStdoutGrep --matches=1 "^filehash:$filehash\$" assertStdoutGrep --matches=1 "^filesize:$size\$" + assertStdoutGrep --matches=1 "^date:$date\$" assertStdoutGrep --matches=1 "^\.author:$SIDB1\$" assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$" assertStdoutGrep --matches=1 "^\.readonly:0\$" @@ -238,23 +242,27 @@ setup_ExtractManifestFileAfterAdd() { setup_rhizome echo "A test file" >file1 executeOk_servald rhizome add file $SIDB1 file1 file1.manifest + extract_stdout_rowid rowid executeOk_servald rhizome list assert_rhizome_list --fromhere=1 --author=$SIDB1 file1 extract_manifest_id manifestid file1.manifest extract_manifest_version version file1.manifest extract_manifest_filehash filehash file1.manifest + extract_manifest_date date file1.manifest } test_ExtractManifestFileAfterAdd() { executeOk_servald rhizome export bundle $manifestid file1x.manifest file1x tfw_cat --stdout --stderr - assertStdoutLineCount '==' 9 + assertStdoutLineCount '==' 11 local size=$(( $(cat file1 | wc -c) + 0 )) assertStdoutGrep --matches=1 "^service:file$" assertStdoutGrep --matches=1 "^manifestid:$manifestid\$" assertStdoutGrep --matches=1 "^version:$version\$" - assertStdoutGrep --matches=1 "^inserttime:$rexp_date\$" + assertStdoutGrep --matches=1 "^\.rowid:$rowid\$" + assertStdoutGrep --matches=1 "^\.inserttime:$rexp_date\$" assertStdoutGrep --matches=1 "^filehash:$filehash\$" assertStdoutGrep --matches=1 "^filesize:$size\$" + assertStdoutGrep --matches=1 "^date:$date\$" assertStdoutGrep --matches=1 "^\.author:$SIDB1\$" assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$" assertStdoutGrep --matches=1 "^\.readonly:0\$" @@ -271,29 +279,35 @@ setup_ExtractManifestFileFromExtBlob() { executeOk_servald config set rhizome.external_blobs 1 echo "A test file" >file1 executeOk_servald rhizome add file $SIDB1 file1 file1.manifest + extract_stdout_rowid rowid1 executeOk_servald config set rhizome.external_blobs 0 echo "Another test file" >file2 executeOk_servald rhizome add file $SIDB1 file2 file2.manifest + extract_stdout_rowid rowid2 executeOk_servald rhizome list assert_rhizome_list --fromhere=1 --author=$SIDB1 file1 file2 extract_manifest_id manifestid1 file1.manifest extract_manifest_version version1 file1.manifest extract_manifest_filehash filehash1 file1.manifest + extract_manifest_date date1 file1.manifest extract_manifest_id manifestid2 file2.manifest extract_manifest_version version2 file2.manifest extract_manifest_filehash filehash2 file2.manifest + extract_manifest_date date2 file2.manifest } test_ExtractManifestFileFromExtBlob() { executeOk_servald rhizome export bundle $manifestid1 file1x.manifest file1x tfw_cat --stdout --stderr - assertStdoutLineCount '==' 9 + assertStdoutLineCount '==' 11 local size=$(( $(cat file1 | wc -c) + 0 )) assertStdoutGrep --matches=1 "^service:file$" assertStdoutGrep --matches=1 "^manifestid:$manifestid1\$" assertStdoutGrep --matches=1 "^version:$version1\$" - assertStdoutGrep --matches=1 "^inserttime:$rexp_date\$" + assertStdoutGrep --matches=1 "^\.rowid:$rowid1\$" + assertStdoutGrep --matches=1 "^\.inserttime:$rexp_date\$" assertStdoutGrep --matches=1 "^filehash:$filehash1\$" assertStdoutGrep --matches=1 "^filesize:$size\$" + assertStdoutGrep --matches=1 "^date:$date1\$" assertStdoutGrep --matches=1 "^\.author:$SIDB1\$" assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$" assertStdoutGrep --matches=1 "^\.readonly:0\$" @@ -303,14 +317,16 @@ test_ExtractManifestFileFromExtBlob() { assert diff file1 file1x executeOk_servald rhizome export bundle $manifestid2 file2x.manifest file2x tfw_cat --stdout --stderr - assertStdoutLineCount '==' 9 + assertStdoutLineCount '==' 11 local size=$(( $(cat file2 | wc -c) + 0 )) assertStdoutGrep --matches=1 "^service:file$" assertStdoutGrep --matches=1 "^manifestid:$manifestid2\$" assertStdoutGrep --matches=1 "^version:$version2\$" - assertStdoutGrep --matches=1 "^inserttime:$rexp_date\$" + assertStdoutGrep --matches=1 "^\.rowid:$rowid2\$" + assertStdoutGrep --matches=1 "^\.inserttime:$rexp_date\$" assertStdoutGrep --matches=1 "^filehash:$filehash2\$" assertStdoutGrep --matches=1 "^filesize:$size\$" + assertStdoutGrep --matches=1 "^date:$date2\$" assertStdoutGrep --matches=1 "^\.author:$SIDB1\$" assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$" assertStdoutGrep --matches=1 "^\.readonly:0\$" @@ -342,26 +358,30 @@ setup_ExtractManifestToStdout() { setup_rhizome echo "A test file" >file1 executeOk_servald rhizome add file $SIDB1 file1 file1.manifest + extract_stdout_rowid rowid extract_manifest_id manifestid file1.manifest extract_manifest_version version file1.manifest extract_manifest_filehash filehash file1.manifest + extract_manifest_date date file1.manifest } test_ExtractManifestToStdout() { executeOk_servald rhizome export manifest $manifestid - - assertStdoutLineCount '>=' 9 + assertStdoutLineCount '>=' 11 local size=$(( $(cat file1 | wc -c) + 0 )) - assertStdoutGrep --line=..9 --matches=1 "^service:file$" - assertStdoutGrep --line=..9 --matches=1 "^manifestid:$manifestid\$" - assertStdoutGrep --line=..9 --matches=1 "^version:$version\$" - assertStdoutGrep --line=..9 --matches=1 "^inserttime:$rexp_date\$" - assertStdoutGrep --line=..9 --matches=1 "^filehash:$filehash\$" - assertStdoutGrep --line=..9 --matches=1 "^filesize:$size\$" - assertStdoutGrep --line=..9 --matches=1 "^\.author:$SIDB1\$" - assertStdoutGrep --line=..9 --matches=1 "^\.secret:$rexp_bundlesecret\$" - assertStdoutGrep --line=..9 --matches=1 "^\.readonly:0\$" - assertStdoutGrep --line=10 --matches=1 "^manifest:" - replayStdout | $SED -n '10s/^manifest://p' >file1x.manifest - replayStdout | $SED -n '11,$p' >>file1x.manifest + assertStdoutGrep --line=..11 --matches=1 "^service:file$" + assertStdoutGrep --line=..11 --matches=1 "^manifestid:$manifestid\$" + assertStdoutGrep --line=..11 --matches=1 "^version:$version\$" + assertStdoutGrep --line=..11 --matches=1 "^\.rowid:$rowid\$" + assertStdoutGrep --line=..11 --matches=1 "^\.inserttime:$rexp_date\$" + assertStdoutGrep --line=..11 --matches=1 "^filehash:$filehash\$" + assertStdoutGrep --line=..11 --matches=1 "^filesize:$size\$" + assertStdoutGrep --line=..11 --matches=1 "^date:$date\$" + assertStdoutGrep --line=..11 --matches=1 "^\.author:$SIDB1\$" + assertStdoutGrep --line=..11 --matches=1 "^\.secret:$rexp_bundlesecret\$" + assertStdoutGrep --line=..11 --matches=1 "^\.readonly:0\$" + assertStdoutGrep --line=12 --matches=1 "^manifest:" + replayStdout | $SED -n '12s/^manifest://p' >file1x.manifest + replayStdout | $SED -n '13,$p' >>file1x.manifest cat file1.manifest >file1n.manifest echo >>file1n.manifest tfw_cat file1n.manifest file1x.manifest @@ -374,23 +394,27 @@ setup_ExtractManifestAfterAddNoAuthor() { setup_rhizome echo "A test file" >file1 executeOk_servald rhizome add file '' file1 file1.manifest + extract_stdout_rowid rowid executeOk_servald rhizome list assert_rhizome_list --fromhere=0 file1 extract_manifest_id manifestid file1.manifest extract_manifest_version version file1.manifest extract_manifest_filehash filehash file1.manifest + extract_manifest_date date file1.manifest } test_ExtractManifestAfterAddNoAuthor() { executeOk_servald rhizome export manifest $manifestid file1x.manifest assert diff file1.manifest file1x.manifest - assertStdoutLineCount '==' 7 + assertStdoutLineCount '==' 9 local size=$(( $(cat file1 | wc -c) + 0 )) assertStdoutGrep --matches=1 "^service:file$" assertStdoutGrep --matches=1 "^manifestid:$manifestid\$" assertStdoutGrep --matches=1 "^version:$version\$" - assertStdoutGrep --matches=1 "^inserttime:$rexp_date\$" + assertStdoutGrep --matches=1 "^\.rowid:$rowid\$" + assertStdoutGrep --matches=1 "^\.inserttime:$rexp_date\$" assertStdoutGrep --matches=1 "^filehash:$filehash\$" assertStdoutGrep --matches=1 "^filesize:$size\$" + assertStdoutGrep --matches=1 "^date:$date\$" assertStdoutGrep --matches=1 "^\.readonly:1\$" } @@ -430,24 +454,28 @@ setup_ExtractFileAfterAdd() { echo "A test file" >file1 executeOk_servald rhizome add file $SIDB1 file1 file1.manifest tfw_cat --stderr + extract_stdout_rowid rowid executeOk_servald rhizome list assert_rhizome_list --fromhere=1 --author=$SIDB1 file1 extract_manifest_id manifestid file1.manifest extract_manifest_version version file1.manifest extract_manifest_filehash filehash file1.manifest + extract_manifest_date date file1.manifest } test_ExtractFileAfterAdd() { executeOk_servald rhizome extract file $manifestid file1x tfw_cat --stderr assert diff file1 file1x local size=$(( $(cat file1 | wc -c) + 0 )) - assertStdoutLineCount '==' 9 + assertStdoutLineCount '==' 11 assertStdoutGrep --matches=1 "^service:file$" assertStdoutGrep --matches=1 "^manifestid:$manifestid\$" assertStdoutGrep --matches=1 "^version:$version\$" - assertStdoutGrep --matches=1 "^inserttime:$rexp_date\$" + assertStdoutGrep --matches=1 "^\.rowid:$rowid\$" + assertStdoutGrep --matches=1 "^\.inserttime:$rexp_date\$" assertStdoutGrep --matches=1 "^filehash:$filehash\$" assertStdoutGrep --matches=1 "^filesize:$size\$" + assertStdoutGrep --matches=1 "^date:$date\$" assertStdoutGrep --matches=1 "^\.author:$SIDB1\$" assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$" assertStdoutGrep --matches=1 "^\.readonly:0\$" @@ -1013,9 +1041,11 @@ setup_ImportOwnBundle() { echo "Hello from B" >fileB executeOk_servald rhizome add file $SIDB2 fileB fileB.manifest assert_stdout_add_file fileB + extract_stdout_rowid rowid extract_manifest_id manifestid fileB.manifest extract_manifest_version version fileB.manifest extract_manifest_filehash filehash fileB.manifest + extract_manifest_date date fileB.manifest rm -f $SERVALINSTANCE_PATH/rhizome.db executeOk_servald rhizome list assert_rhizome_list @@ -1031,14 +1061,16 @@ test_ImportOwnBundle() { tfw_cat --stderr assert cmp fileB.manifest fileBx.manifest assert cmp fileB fileBx - assertStdoutLineCount '==' 9 + assertStdoutLineCount '==' 11 local size=$(( $(cat fileB | wc -c) + 0 )) assertStdoutGrep --matches=1 "^service:file$" assertStdoutGrep --matches=1 "^manifestid:$manifestid\$" assertStdoutGrep --matches=1 "^version:$version\$" - assertStdoutGrep --matches=1 "^inserttime:$rexp_date\$" + assertStdoutGrep --matches=1 "^\.rowid:$rowid\$" + assertStdoutGrep --matches=1 "^\.inserttime:$rexp_date\$" assertStdoutGrep --matches=1 "^filehash:$filehash\$" assertStdoutGrep --matches=1 "^filesize:$size\$" + assertStdoutGrep --matches=1 "^date:$date\$" assertStdoutGrep --matches=1 "^\.author:$SIDB2\$" assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$" assertStdoutGrep --matches=1 "^\.readonly:0\$"