From a48f3687785b2c138b2c47848bd05512fc893a0b Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 6 Apr 2010 12:45:30 -0700 Subject: [PATCH] fix notmuch_message_file_get_header fix notmuch_message_file_get_header to always return the first instance of the header you are looking for Signed-off-by: Dirk Hohndel --- lib/message-file.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/message-file.c b/lib/message-file.c index 3a1a681d..0c152a39 100644 --- a/lib/message-file.c +++ b/lib/message-file.c @@ -318,9 +318,15 @@ notmuch_message_file_get_header (notmuch_message_file_t *message, match = (strcasecmp (header, header_desired) == 0); decoded_value = g_mime_utils_header_decode_text (message->value.str); - - g_hash_table_insert (message->headers, header, decoded_value); - + if (g_hash_table_lookup (message->headers, header) == NULL) { + /* Only insert if we don't have a value for this header, yet. + * This way we always return the FIRST instance of any header + * we search for + * FIXME: we should be returning ALL instances of a header + * or at least provide a way to iterate over them + */ + g_hash_table_insert (message->headers, header, decoded_value); + } if (match) return decoded_value; }