]> git.notmuchmail.org Git - notmuch/blobdiff - lib/message.cc
cli/reindex: destroy stashed session keys when --decrypt=false
[notmuch] / lib / message.cc
index 4ab0ed269fd0bca5ce83142aeb97a718a5a1bdc8..d5db89b6606c7da011c2a80c5ce460f769f32650 100644 (file)
@@ -1961,7 +1961,7 @@ _notmuch_message_frozen (notmuch_message_t *message)
 
 notmuch_status_t
 notmuch_message_reindex (notmuch_message_t *message,
-                        notmuch_indexopts_t unused (*indexopts))
+                        notmuch_indexopts_t *indexopts)
 {
     notmuch_database_t *notmuch = NULL;
     notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
@@ -1999,6 +1999,15 @@ notmuch_message_reindex (notmuch_message_t *message,
        goto DONE;
     }
 
+    ret = notmuch_message_remove_all_properties_with_prefix (message, "index.");
+    if (ret)
+       goto DONE; /* XXX TODO: distinguish from other error returns above? */
+    if (indexopts && notmuch_indexopts_get_decrypt_policy (indexopts) == NOTMUCH_DECRYPT_FALSE) {
+       ret = notmuch_message_remove_all_properties (message, "session-key");
+       if (ret)
+           goto DONE;
+    }
+
     /* re-add the filenames with the associated indexopts */
     for (; notmuch_filenames_valid (orig_filenames);
         notmuch_filenames_move_to_next (orig_filenames)) {
@@ -2038,7 +2047,7 @@ notmuch_message_reindex (notmuch_message_t *message,
        if (found == 0)
            _notmuch_message_set_header_values (message, date, from, subject);
 
-       ret = _notmuch_message_index_file (message, message_file);
+       ret = _notmuch_message_index_file (message, indexopts, message_file);
 
        if (ret == NOTMUCH_STATUS_FILE_ERROR)
            continue;