aboutsummaryrefslogtreecommitdiff
path: root/lib/index.cc
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2017-12-08 01:23:58 -0500
committerDavid Bremner <david@tethera.net>2017-12-08 08:08:46 -0400
commitd137170b23f8ccd9f967445e101d6f694df1cad4 (patch)
treea9d783de0ce8bcfcd59f49703e82adb5c8c240ff /lib/index.cc
parent181d4091c408b8ca014ec245ecdae602942b70ce (diff)
crypto: record whether an actual decryption attempt happened
In our consolidation of _notmuch_crypto_decrypt, the callers lost track a little bit of whether any actual decryption was attempted. Now that we have the more-subtle "auto" policy, it's possible that _notmuch_crypto_decrypt could be called without having any actual decryption take place. This change lets the callers be a little bit smarter about whether or not any decryption was actually attempted.
Diffstat (limited to 'lib/index.cc')
-rw-r--r--lib/index.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/index.cc b/lib/index.cc
index af999bd3..3914012a 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -548,12 +548,19 @@ _index_encrypted_mime_part (notmuch_message_t *message,
}
}
#endif
- clear = _notmuch_crypto_decrypt (notmuch_indexopts_get_decrypt_policy (indexopts),
+ bool attempted = false;
+ clear = _notmuch_crypto_decrypt (&attempted, notmuch_indexopts_get_decrypt_policy (indexopts),
message, crypto_ctx, encrypted_data, NULL, &err);
- if (err) {
- _notmuch_database_log (notmuch, "Failed to decrypt during indexing. (%d:%d) [%s]\n",
- err->domain, err->code, err->message);
- g_error_free(err);
+ if (!attempted)
+ return;
+ if (err || !clear) {
+ if (err) {
+ _notmuch_database_log (notmuch, "Failed to decrypt during indexing. (%d:%d) [%s]\n",
+ err->domain, err->code, err->message);
+ g_error_free(err);
+ } else {
+ _notmuch_database_log (notmuch, "Failed to decrypt during indexing. (unknown error)\n");
+ }
/* Indicate that we failed to decrypt during indexing */
status = notmuch_message_add_property (message, "index.decryption", "failure");
if (status)