unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [RFC PATCH 05/14] new: use new URL-based filenames for messages
@ 2012-06-25 20:51 Ethan Glasser-Camp
  2012-06-25 20:51 ` [RFC PATCH 06/14] maildir URIs can be used in tags_to_maildir_flags Ethan Glasser-Camp
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Ethan Glasser-Camp @ 2012-06-25 20:51 UTC (permalink / raw)
  To: notmuch

This commit breaks a bunch of tests; fixes follow.

Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>
---
 notmuch-new.c |   27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index 938ae29..1f11b2c 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -287,7 +287,7 @@ add_files (notmuch_database_t *notmuch,
 {
     DIR *dir = NULL;
     struct dirent *entry = NULL;
-    char *next = NULL;
+    char *next = NULL, *path_uri = NULL;
     time_t fs_mtime, db_mtime;
     notmuch_status_t status, ret = NOTMUCH_STATUS_SUCCESS;
     notmuch_message_t *message = NULL;
@@ -315,7 +315,16 @@ add_files (notmuch_database_t *notmuch,
 
     fs_mtime = st.st_mtime;
 
-    status = notmuch_database_get_directory (notmuch, path, &directory);
+    /* maildir URIs should never have a hostname component, but
+     * uriparser doesn't parse paths correctly if they start with //,
+     * as in scheme://host//path.
+     */
+    if (path[0] == '/')
+	path_uri = talloc_asprintf (notmuch, "maildir://%s", path);
+    else
+	path_uri = talloc_asprintf (notmuch, "maildir:///%s", path);
+
+    status = notmuch_database_get_directory (notmuch, path_uri, &directory);
     if (status) {
 	ret = status;
 	goto DONE;
@@ -423,7 +432,7 @@ add_files (notmuch_database_t *notmuch,
 	       strcmp (notmuch_filenames_get (db_files), entry->d_name) < 0)
 	{
 	    char *absolute = talloc_asprintf (state->removed_files,
-					      "%s/%s", path,
+					      "%s/%s", path_uri,
 					      notmuch_filenames_get (db_files));
 
 	    _filename_list_add (state->removed_files, absolute);
@@ -439,7 +448,7 @@ add_files (notmuch_database_t *notmuch,
 	    if (strcmp (filename, entry->d_name) < 0)
 	    {
 		char *absolute = talloc_asprintf (state->removed_directories,
-						  "%s/%s", path, filename);
+						  "%s/%s", path_uri, filename);
 
 		_filename_list_add (state->removed_directories, absolute);
 	    }
@@ -467,7 +476,7 @@ add_files (notmuch_database_t *notmuch,
 
 	/* We're now looking at a regular file that doesn't yet exist
 	 * in the database, so add it. */
-	next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
+	next = talloc_asprintf (notmuch, "%s/%s", path_uri, entry->d_name);
 
 	state->processed_files++;
 
@@ -559,7 +568,7 @@ add_files (notmuch_database_t *notmuch,
     while (notmuch_filenames_valid (db_files))
     {
 	char *absolute = talloc_asprintf (state->removed_files,
-					  "%s/%s", path,
+					  "%s/%s", path_uri,
 					  notmuch_filenames_get (db_files));
 
 	_filename_list_add (state->removed_files, absolute);
@@ -570,7 +579,7 @@ add_files (notmuch_database_t *notmuch,
     while (notmuch_filenames_valid (db_subdirs))
     {
 	char *absolute = talloc_asprintf (state->removed_directories,
-					  "%s/%s", path,
+					  "%s/%s", path_uri,
 					  notmuch_filenames_get (db_subdirs));
 
 	_filename_list_add (state->removed_directories, absolute);
@@ -584,9 +593,11 @@ add_files (notmuch_database_t *notmuch,
      * same second.  This may lead to unnecessary re-scans, but it
      * avoids overlooking messages. */
     if (fs_mtime != stat_time)
-	_filename_list_add (state->directory_mtimes, path)->mtime = fs_mtime;
+	_filename_list_add (state->directory_mtimes, path_uri)->mtime = fs_mtime;
 
   DONE:
+    if (path_uri)
+	talloc_free (path_uri);
     if (next)
 	talloc_free (next);
     if (dir)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-06-28 20:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-25 20:51 [RFC PATCH 05/14] new: use new URL-based filenames for messages Ethan Glasser-Camp
2012-06-25 20:51 ` [RFC PATCH 06/14] maildir URIs can be used in tags_to_maildir_flags Ethan Glasser-Camp
2012-06-25 20:51 ` [RFC PATCH 07/14] Update tests that need to see filenames to use URIs Ethan Glasser-Camp
2012-06-25 20:51 ` [RFC PATCH 08/14] Don't cache corpus.mail Ethan Glasser-Camp
2012-06-25 20:51 ` [RFC PATCH 09/14] Fix atomicity test to work without relocatable mailstores Ethan Glasser-Camp
2012-06-25 20:51 ` [RFC PATCH 10/14] new: add "scan" option Ethan Glasser-Camp
2012-06-28 20:54   ` Mark Walters
2012-06-25 20:51 ` [RFC PATCH 11/14] notmuch-new: pull out useful bits of add_files_recursive Ethan Glasser-Camp
2012-06-25 20:51 ` [RFC PATCH 12/14] mailstore: support for mbox:// URIs Ethan Glasser-Camp
2012-06-25 20:51 ` [RFC PATCH 13/14] Tests for mbox support Ethan Glasser-Camp
2012-06-25 20:51 ` [RFC PATCH 14/14] new: Add scan support for mbox:// URIs Ethan Glasser-Camp

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).