From e98592a7c1a77067a860a3eab4595560efc038eb Mon Sep 17 00:00:00 2001 From: Jeremy Lakeman Date: Tue, 27 Aug 2013 15:11:56 +0930 Subject: [PATCH] Don't update the database author if we already know it --- meshms.c | 2 ++ rhizome_crypto.c | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/meshms.c b/meshms.c index 1bd9ee9d..b62ebfc8 100644 --- a/meshms.c +++ b/meshms.c @@ -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{ diff --git a/rhizome_crypto.c b/rhizome_crypto.c index 8860a0fc..6c4d1e82 100644 --- a/rhizome_crypto.c +++ b/rhizome_crypto.c @@ -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