[PATCH v2 3/8] Not all filenames need to be converted to absolute paths
authorEthan Glasser-Camp <ethan.glasser.camp@gmail.com>
Sun, 1 Jul 2012 16:39:45 +0000 (12:39 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:55 +0000 (09:47 -0800)
89/3f73176959a5c6a8b97519fbd32ba8dc9c91a8 [new file with mode: 0644]

diff --git a/89/3f73176959a5c6a8b97519fbd32ba8dc9c91a8 b/89/3f73176959a5c6a8b97519fbd32ba8dc9c91a8
new file mode 100644 (file)
index 0000000..b0e03c8
--- /dev/null
@@ -0,0 +1,124 @@
+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 C9A01431FAF\r
+       for <notmuch@notmuchmail.org>; Sun,  1 Jul 2012 09:45:40 -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 nyal8tMxthgW for <notmuch@notmuchmail.org>;\r
+       Sun,  1 Jul 2012 09:45:40 -0700 (PDT)\r
+Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com\r
+       [209.85.212.169]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 0C076431FBC\r
+       for <notmuch@notmuchmail.org>; Sun,  1 Jul 2012 09:45:37 -0700 (PDT)\r
+Received: by wibhm2 with SMTP id hm2so2251711wib.2\r
+       for <notmuch@notmuchmail.org>; Sun, 01 Jul 2012 09:45:36 -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:in-reply-to:references;\r
+       bh=HC9oKICFAU9pcKU4tGq9SgYD0TPlU+WfXGf3wVKoDTM=;\r
+       b=jBqCxiYjfqa2z7RAoNPkPau2QrRxYZmXhrggJGun6RzSASjmFy+u+G24Zkd+ScnKku\r
+       isKdnK4PRgE2SUwSbDBsl1deSjlbYrGdFKuYn/gnOFG5Aos9CnAPbv7z95ns5AantbTy\r
+       ouX19HaKE6ZlhcO++oV4vKUg9ohfJtbdD28MqgwCdwic9/cE2hb4Y75+ZdaNo6xLFZkm\r
+       qEOYbiBgnRjdY2VZ0uTezspHE4sJRMNdeGwMLJ+yRKnzrsEokFJN98VPzhHzdA0ip+Du\r
+       WeygZzXKdkEjLopelevRBrOtK5soaxCGf/sAMM7UJmslSWsJ118dtAQl+tF8sdo/hSf5\r
+       yPSg==\r
+Received: by 10.216.150.140 with SMTP id z12mr446426wej.68.1341161136632;\r
+       Sun, 01 Jul 2012 09:45:36 -0700 (PDT)\r
+Received: from localhost ([195.24.209.21])\r
+       by mx.google.com with ESMTPS id ch9sm35152621wib.8.2012.07.01.09.45.28\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sun, 01 Jul 2012 09:45:35 -0700 (PDT)\r
+From: Ethan Glasser-Camp <ethan.glasser.camp@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 3/8] Not all filenames need to be converted to absolute\r
+       paths\r
+Date: Sun,  1 Jul 2012 12:39:45 -0400\r
+Message-Id: <1341160790-14525-4-git-send-email-ethan@betacantrips.com>\r
+X-Mailer: git-send-email 1.7.9.5\r
+In-Reply-To: <1341160790-14525-1-git-send-email-ethan@betacantrips.com>\r
+References:\r
+ <CAOJ+Ob0MSOez2MvD2fCgF7t32kFPk4g2+xCud88QmBLt_b5pOA@mail.gmail.com>\r
+       <1341160790-14525-1-git-send-email-ethan@betacantrips.com>\r
+Cc: Ethan Glasser-Camp <ethan@betacantrips.com>\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: Sun, 01 Jul 2012 16:45:41 -0000\r
+\r
+_notmuch_message_ensure_filename_list converts "relative" paths, such\r
+as those stored in Xapian until now, to "absolute" paths. However,\r
+URLs are already absolute, and prepending the database path will just\r
+confuse matters.\r
+\r
+Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>\r
+---\r
+ lib/message.cc |   20 +++++++++++++++++---\r
+ 1 file changed, 17 insertions(+), 3 deletions(-)\r
+\r
+diff --git a/lib/message.cc b/lib/message.cc\r
+index 978de06..235185c 100644\r
+--- a/lib/message.cc\r
++++ b/lib/message.cc\r
+@@ -21,6 +21,7 @@\r
+ #include "notmuch-private.h"\r
+ #include "database-private.h"\r
+ \r
++#include <uriparser/Uri.h>\r
+ #include <stdint.h>\r
+ \r
+ #include <gmime/gmime.h>\r
+@@ -682,6 +683,8 @@ _notmuch_message_ensure_filename_list (notmuch_message_t *message)\r
+       const char *db_path, *directory, *basename, *filename;\r
+       char *colon, *direntry = NULL;\r
+       unsigned int directory_id;\r
++      UriUriA parsed;\r
++      UriParserStateA parser;\r
+ \r
+       direntry = node->string;\r
+ \r
+@@ -700,9 +703,20 @@ _notmuch_message_ensure_filename_list (notmuch_message_t *message)\r
+                                                         message->notmuch,\r
+                                                         directory_id);\r
+ \r
+-      if (strlen (directory))\r
+-          filename = talloc_asprintf (message, "%s/%s/%s",\r
+-                                      db_path, directory, basename);\r
++      parser.uri = &parsed;\r
++\r
++      if (strlen (directory)) {\r
++          /* If directory is a URI, we don't need to append the db_path;\r
++           * it is already an absolute path. */\r
++          if (uriParseUriA (&parser, directory) != URI_SUCCESS ||\r
++              parsed.scheme.first == NULL)\r
++              filename = talloc_asprintf (message, "%s/%s/%s",\r
++                                          db_path, directory, basename);\r
++          else\r
++              filename = talloc_asprintf (message, "%s/%s",\r
++                                          directory, basename);\r
++          uriFreeUriMembersA (&parsed);\r
++      }\r
+       else\r
+           filename = talloc_asprintf (message, "%s/%s",\r
+                                       db_path, basename);\r
+-- \r
+1.7.9.5\r
+\r