mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-22 06:27:51 +00:00
Fix bug in output from "rhizome add file"
When a duplicate is detected, the 'manifestid' field must contain the public key of the existing manifest.
This commit is contained in:
parent
f31c326871
commit
97884ba069
@ -1014,17 +1014,19 @@ int app_rhizome_add_file(int argc, const char *const *argv, struct command_line_
|
||||
);
|
||||
if (ret == -1)
|
||||
return WHY("Manifest not added to Rhizome database");
|
||||
if (!(ret == 0 || ret == 2))
|
||||
return WHYF("Unexpected return value ret=%d", ret);
|
||||
/* If successfully added, overwrite the manifest file so that the Java component that is
|
||||
invoking this command can read it to obtain feedback on the result. */
|
||||
if (manifestpath[0] && rhizome_write_manifest_file(mout, manifestpath) == -1)
|
||||
ret = WHY("Could not overwrite manifest file.");
|
||||
cli_puts("manifestid"); cli_delim(":");
|
||||
cli_puts(rhizome_bytes_to_hex(m->cryptoSignPublic, crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES)); cli_delim("\n");
|
||||
cli_puts(rhizome_bytes_to_hex(mout->cryptoSignPublic, crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES)); cli_delim("\n");
|
||||
cli_puts("filehash"); cli_delim(":");
|
||||
cli_puts(m->fileHexHash); cli_delim("\n");
|
||||
cli_puts(mout->fileHexHash); cli_delim("\n");
|
||||
cli_puts("filesize"); cli_delim(":");
|
||||
cli_printf("%lld", m->fileLength); cli_delim("\n");
|
||||
const char *name = rhizome_manifest_get(m, "name", NULL, 0);
|
||||
cli_printf("%lld", mout->fileLength); cli_delim("\n");
|
||||
const char *name = rhizome_manifest_get(mout, "name", NULL, 0);
|
||||
if (name) {
|
||||
cli_puts("name"); cli_delim(":");
|
||||
cli_puts(name); cli_delim("\n");
|
||||
|
@ -824,6 +824,7 @@ int rhizome_find_duplicate(const rhizome_manifest *m, rhizome_manifest **found)
|
||||
&& (lengthq == -1 || lengthq == m->fileLength)
|
||||
&& (!filehashq || strncmp(filehashq, m->fileHexHash, SHA512_DIGEST_STRING_LENGTH) == 0)
|
||||
) {
|
||||
rhizome_hex_to_bytes(manifestid, mq->cryptoSignPublic, crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES*2);
|
||||
memcpy(mq->fileHexHash, m->fileHexHash, SHA512_DIGEST_STRING_LENGTH);
|
||||
mq->fileHashedP = 1;
|
||||
mq->fileLength = m->fileLength;
|
||||
|
@ -302,12 +302,14 @@ test_AddDuplicate() {
|
||||
# on stderr).
|
||||
execute --exit-status=2 $dna rhizome add file file1 file1.manifestA
|
||||
assert [ -s file1.manifestA ]
|
||||
assert_stdout_add_file file1
|
||||
assert_rhizome_list file1 file2
|
||||
strip_signatures file1.manifest file1.manifestA
|
||||
assert diff file1.manifest file1.manifestA
|
||||
# Repeat for second file.
|
||||
execute --exit-status=2 $dna rhizome add file file2 file2.manifestA
|
||||
assert [ -s file2.manifestA ]
|
||||
assert_stdout_add_file file2
|
||||
assert_rhizome_list file1 file2
|
||||
strip_signatures file2.manifest file2.manifestA
|
||||
assert diff file2.manifest file2.manifestA
|
||||
@ -361,6 +363,7 @@ setup_AddUpdateNewVersion() {
|
||||
test_AddUpdateNewVersion() {
|
||||
tfw_cat -v file1_2.manifest
|
||||
executeOk $dna rhizome add file file1_2 file1_2.manifest
|
||||
assert_stdout_add_file file1_2 file1
|
||||
assert_manifest_newer file1.manifest file1_2.manifest
|
||||
# Rhizome store contents reflect new payload.
|
||||
mv -f file1_2.manifest file1.manifest
|
||||
|
Loading…
Reference in New Issue
Block a user