[RFC PATCH 06/13] Pass mailstore to _notmuch_message_index_file

Ethan Glasser-Camp glasse at cs.rpi.edu
Wed Feb 15 14:01:59 PST 2012


From: Ethan Glasser-Camp <ethan at betacantrips.com>

This is the last place where fopen(2) was used and had to be replaced.

Signed-off-by: Ethan Glasser-Camp <ethan at betacantrips.com>
---
 lib/database.cc       |    2 +-
 lib/index.cc          |    5 +++--
 lib/notmuch-private.h |    3 ++-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index ff44e76..0ed4412 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -1743,7 +1743,7 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
 	    date = notmuch_message_file_get_header (message_file, "date");
 	    _notmuch_message_set_header_values (message, date, from, subject);
 
-	    _notmuch_message_index_file (message, filename);
+	    _notmuch_message_index_file (notmuch->mailstore, message, filename);
 	} else {
 	    ret = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;
 	}
diff --git a/lib/index.cc b/lib/index.cc
index d8f8b2b..54b8f73 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -409,7 +409,8 @@ _index_mime_part (notmuch_message_t *message,
 }
 
 notmuch_status_t
-_notmuch_message_index_file (notmuch_message_t *message,
+_notmuch_message_index_file (notmuch_mailstore_t *mailstore,
+			     notmuch_message_t *message,
 			     const char *filename)
 {
     GMimeStream *stream = NULL;
@@ -426,7 +427,7 @@ _notmuch_message_index_file (notmuch_message_t *message,
 	initialized = 1;
     }
 
-    file = fopen (filename, "r");
+    file = notmuch_mailstore_open (mailstore, filename);
     if (! file) {
 	fprintf (stderr, "Error opening %s: %s\n", filename, strerror (errno));
 	ret = NOTMUCH_STATUS_FILE_ERROR;
diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index 2589928..d93891e 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -313,7 +313,8 @@ notmuch_message_get_author (notmuch_message_t *message);
 /* index.cc */
 
 notmuch_status_t
-_notmuch_message_index_file (notmuch_message_t *message,
+_notmuch_message_index_file (notmuch_mailstore_t *mailstore,
+			     notmuch_message_t *message,
 			     const char *filename);
 
 /* message-file.c */
-- 
1.7.5.4



More information about the notmuch mailing list