Don't update the database author if we already know it

This commit is contained in:
Jeremy Lakeman 2013-08-27 15:11:56 +09:30
parent acaedd644c
commit e98592a7c1
2 changed files with 13 additions and 8 deletions

View File

@ -306,6 +306,8 @@ static int append_meshms_buffer(const sid_t *my_sid, struct conversations *conv,
if (conv->found_my_ply){
if (rhizome_retrieve_manifest(conv->my_ply.bundle_id, m))
goto end;
// set the author of the manifest as we should already know that
bcopy(my_sid->binary, m->author, sizeof(m->author));
if (rhizome_find_bundle_author(m))
goto end;
}else{

View File

@ -365,16 +365,19 @@ int rhizome_find_bundle_author(rhizome_manifest *m)
if (!rhizome_bk2secret(m,m->cryptoSignPublic,rs,rs_len,
bkBytes,m->cryptoSignSecret)) {
memcpy(m->author, authorSid, sizeof m->author);
m->haveSecret=EXISTING_BUNDLE_ID;
if (config.debug.rhizome)
DEBUGF("found bundle author sid=%s", alloca_tohex_sid(m->author));
// if this bundle is already in the database, update the author.
if (m->inserttime){
const char *id = rhizome_manifest_get(m, "id", NULL, 0);
if (sqlite_exec_void("UPDATE MANIFESTS SET author='%s' WHERE id='%s';", alloca_tohex_sid(m->author), id) == -1)
WARN("Error updating MANIFESTS author column");
if (memcmp(m->author, authorSid, sizeof m->author)){
memcpy(m->author, authorSid, sizeof m->author);
if (config.debug.rhizome)
DEBUGF("found bundle author sid=%s", alloca_tohex_sid(m->author));
// if this bundle is already in the database, update the author.
if (m->inserttime){
const char *id = rhizome_manifest_get(m, "id", NULL, 0);
if (sqlite_exec_void("UPDATE MANIFESTS SET author='%s' WHERE id='%s';", alloca_tohex_sid(m->author), id) == -1)
WARN("Error updating MANIFESTS author column");
}
}
RETURN(0); // bingo