--- /dev/null
+Return-Path: <ethan.glasser.camp@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 3D9C5431FB6\r
+ for <notmuch@notmuchmail.org>; Mon, 25 Jun 2012 13:52:27 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 1.061\r
+X-Spam-Level: *\r
+X-Spam-Status: No, score=1.061 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.246,\r
+ RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_SORBS_WEB=0.614] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id AIR-5bzUUieL for <notmuch@notmuchmail.org>;\r
+ Mon, 25 Jun 2012 13:52:25 -0700 (PDT)\r
+Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com\r
+ [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ 5396F431FAF for <notmuch@notmuchmail.org>; Mon, 25 Jun 2012 13:52:25 -0700\r
+ (PDT)\r
+Received: by wgbdt14 with SMTP id dt14so3709395wgb.2\r
+ for <notmuch@notmuchmail.org>; Mon, 25 Jun 2012 13:52:24 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:x-mailer;\r
+ bh=YqK8BU9axMj+Rr5tO1sFHtUxlwDAX28vQ9xpC//GUDw=;\r
+ b=CGevjzK+6x+1hcxjFEcIbktSvOK62V5PAqbXTAPDZippKuVfUj2vA6sLFhvHDsywMo\r
+ 4xBcKCcuGVuZFwhwpGNZx+kRVu53CswPa9rjhD8YmWjqZpTPjTDZG2cWY5Cvg+BVBVuY\r
+ lNgrEijURGjSDWoQ/RBMj7wPhsyGcluvVyOvA65UsTMhTkTpaCzqkBJR72QfxTQJCfza\r
+ pSLVeqO1saQJBx9kzKE/012sG6vr5DMDyMuZk3nu10QUMOr/2NzVhRmlZs/iSHd9bvXW\r
+ CtCTX8JHInzrLVZRqV5G5ro5FqTXV0a3qHcFdreGAxL0mrtqqkW7Bq9OTfYl+03MP1Uh\r
+ S4Ow==\r
+Received: by 10.180.83.197 with SMTP id s5mr27227608wiy.9.1340657544059;\r
+ Mon, 25 Jun 2012 13:52:24 -0700 (PDT)\r
+Received: from localhost ([195.24.209.21])\r
+ by mx.google.com with ESMTPS id f7sm77266wiv.2.2012.06.25.13.52.18\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Mon, 25 Jun 2012 13:52:23 -0700 (PDT)\r
+From: Ethan Glasser-Camp <ethan.glasser.camp@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [RFC PATCH 05/14] new: use new URL-based filenames for messages\r
+Date: Mon, 25 Jun 2012 16:51:48 -0400\r
+Message-Id: <1340657517-6539-1-git-send-email-ethan@betacantrips.com>\r
+X-Mailer: git-send-email 1.7.9.5\r
+X-Mailman-Approved-At: Tue, 26 Jun 2012 03:51:54 -0700\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 25 Jun 2012 20:52:27 -0000\r
+\r
+This commit breaks a bunch of tests; fixes follow.\r
+\r
+Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>\r
+---\r
+ notmuch-new.c | 27 +++++++++++++++++++--------\r
+ 1 file changed, 19 insertions(+), 8 deletions(-)\r
+\r
+diff --git a/notmuch-new.c b/notmuch-new.c\r
+index 938ae29..1f11b2c 100644\r
+--- a/notmuch-new.c\r
++++ b/notmuch-new.c\r
+@@ -287,7 +287,7 @@ add_files (notmuch_database_t *notmuch,\r
+ {\r
+ DIR *dir = NULL;\r
+ struct dirent *entry = NULL;\r
+- char *next = NULL;\r
++ char *next = NULL, *path_uri = NULL;\r
+ time_t fs_mtime, db_mtime;\r
+ notmuch_status_t status, ret = NOTMUCH_STATUS_SUCCESS;\r
+ notmuch_message_t *message = NULL;\r
+@@ -315,7 +315,16 @@ add_files (notmuch_database_t *notmuch,\r
+ \r
+ fs_mtime = st.st_mtime;\r
+ \r
+- status = notmuch_database_get_directory (notmuch, path, &directory);\r
++ /* maildir URIs should never have a hostname component, but\r
++ * uriparser doesn't parse paths correctly if they start with //,\r
++ * as in scheme://host//path.\r
++ */\r
++ if (path[0] == '/')\r
++ path_uri = talloc_asprintf (notmuch, "maildir://%s", path);\r
++ else\r
++ path_uri = talloc_asprintf (notmuch, "maildir:///%s", path);\r
++\r
++ status = notmuch_database_get_directory (notmuch, path_uri, &directory);\r
+ if (status) {\r
+ ret = status;\r
+ goto DONE;\r
+@@ -423,7 +432,7 @@ add_files (notmuch_database_t *notmuch,\r
+ strcmp (notmuch_filenames_get (db_files), entry->d_name) < 0)\r
+ {\r
+ char *absolute = talloc_asprintf (state->removed_files,\r
+- "%s/%s", path,\r
++ "%s/%s", path_uri,\r
+ notmuch_filenames_get (db_files));\r
+ \r
+ _filename_list_add (state->removed_files, absolute);\r
+@@ -439,7 +448,7 @@ add_files (notmuch_database_t *notmuch,\r
+ if (strcmp (filename, entry->d_name) < 0)\r
+ {\r
+ char *absolute = talloc_asprintf (state->removed_directories,\r
+- "%s/%s", path, filename);\r
++ "%s/%s", path_uri, filename);\r
+ \r
+ _filename_list_add (state->removed_directories, absolute);\r
+ }\r
+@@ -467,7 +476,7 @@ add_files (notmuch_database_t *notmuch,\r
+ \r
+ /* We're now looking at a regular file that doesn't yet exist\r
+ * in the database, so add it. */\r
+- next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);\r
++ next = talloc_asprintf (notmuch, "%s/%s", path_uri, entry->d_name);\r
+ \r
+ state->processed_files++;\r
+ \r
+@@ -559,7 +568,7 @@ add_files (notmuch_database_t *notmuch,\r
+ while (notmuch_filenames_valid (db_files))\r
+ {\r
+ char *absolute = talloc_asprintf (state->removed_files,\r
+- "%s/%s", path,\r
++ "%s/%s", path_uri,\r
+ notmuch_filenames_get (db_files));\r
+ \r
+ _filename_list_add (state->removed_files, absolute);\r
+@@ -570,7 +579,7 @@ add_files (notmuch_database_t *notmuch,\r
+ while (notmuch_filenames_valid (db_subdirs))\r
+ {\r
+ char *absolute = talloc_asprintf (state->removed_directories,\r
+- "%s/%s", path,\r
++ "%s/%s", path_uri,\r
+ notmuch_filenames_get (db_subdirs));\r
+ \r
+ _filename_list_add (state->removed_directories, absolute);\r
+@@ -584,9 +593,11 @@ add_files (notmuch_database_t *notmuch,\r
+ * same second. This may lead to unnecessary re-scans, but it\r
+ * avoids overlooking messages. */\r
+ if (fs_mtime != stat_time)\r
+- _filename_list_add (state->directory_mtimes, path)->mtime = fs_mtime;\r
++ _filename_list_add (state->directory_mtimes, path_uri)->mtime = fs_mtime;\r
+ \r
+ DONE:\r
++ if (path_uri)\r
++ talloc_free (path_uri);\r
+ if (next)\r
+ talloc_free (next);\r
+ if (dir)\r
+-- \r
+1.7.9.5\r
+\r