From 063897ebce4221d27ef3d21aa0d740677391b104 Mon Sep 17 00:00:00 2001 From: Ethan Glasser-Camp Date: Mon, 2 Jul 2012 12:39:45 +2000 Subject: [PATCH] [PATCH v2 3/8] Not all filenames need to be converted to absolute paths --- 89/3f73176959a5c6a8b97519fbd32ba8dc9c91a8 | 124 ++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 89/3f73176959a5c6a8b97519fbd32ba8dc9c91a8 diff --git a/89/3f73176959a5c6a8b97519fbd32ba8dc9c91a8 b/89/3f73176959a5c6a8b97519fbd32ba8dc9c91a8 new file mode 100644 index 000000000..b0e03c8e3 --- /dev/null +++ b/89/3f73176959a5c6a8b97519fbd32ba8dc9c91a8 @@ -0,0 +1,124 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id C9A01431FAF + for ; Sun, 1 Jul 2012 09:45:40 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 1.061 +X-Spam-Level: * +X-Spam-Status: No, score=1.061 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.246, + RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_SORBS_WEB=0.614] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id nyal8tMxthgW for ; + Sun, 1 Jul 2012 09:45:40 -0700 (PDT) +Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com + [209.85.212.169]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 0C076431FBC + for ; Sun, 1 Jul 2012 09:45:37 -0700 (PDT) +Received: by wibhm2 with SMTP id hm2so2251711wib.2 + for ; Sun, 01 Jul 2012 09:45:36 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; + bh=HC9oKICFAU9pcKU4tGq9SgYD0TPlU+WfXGf3wVKoDTM=; + b=jBqCxiYjfqa2z7RAoNPkPau2QrRxYZmXhrggJGun6RzSASjmFy+u+G24Zkd+ScnKku + isKdnK4PRgE2SUwSbDBsl1deSjlbYrGdFKuYn/gnOFG5Aos9CnAPbv7z95ns5AantbTy + ouX19HaKE6ZlhcO++oV4vKUg9ohfJtbdD28MqgwCdwic9/cE2hb4Y75+ZdaNo6xLFZkm + qEOYbiBgnRjdY2VZ0uTezspHE4sJRMNdeGwMLJ+yRKnzrsEokFJN98VPzhHzdA0ip+Du + WeygZzXKdkEjLopelevRBrOtK5soaxCGf/sAMM7UJmslSWsJ118dtAQl+tF8sdo/hSf5 + yPSg== +Received: by 10.216.150.140 with SMTP id z12mr446426wej.68.1341161136632; + Sun, 01 Jul 2012 09:45:36 -0700 (PDT) +Received: from localhost ([195.24.209.21]) + by mx.google.com with ESMTPS id ch9sm35152621wib.8.2012.07.01.09.45.28 + (version=TLSv1/SSLv3 cipher=OTHER); + Sun, 01 Jul 2012 09:45:35 -0700 (PDT) +From: Ethan Glasser-Camp +To: notmuch@notmuchmail.org +Subject: [PATCH v2 3/8] Not all filenames need to be converted to absolute + paths +Date: Sun, 1 Jul 2012 12:39:45 -0400 +Message-Id: <1341160790-14525-4-git-send-email-ethan@betacantrips.com> +X-Mailer: git-send-email 1.7.9.5 +In-Reply-To: <1341160790-14525-1-git-send-email-ethan@betacantrips.com> +References: + + <1341160790-14525-1-git-send-email-ethan@betacantrips.com> +Cc: Ethan Glasser-Camp +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 01 Jul 2012 16:45:41 -0000 + +_notmuch_message_ensure_filename_list converts "relative" paths, such +as those stored in Xapian until now, to "absolute" paths. However, +URLs are already absolute, and prepending the database path will just +confuse matters. + +Signed-off-by: Ethan Glasser-Camp +--- + lib/message.cc | 20 +++++++++++++++++--- + 1 file changed, 17 insertions(+), 3 deletions(-) + +diff --git a/lib/message.cc b/lib/message.cc +index 978de06..235185c 100644 +--- a/lib/message.cc ++++ b/lib/message.cc +@@ -21,6 +21,7 @@ + #include "notmuch-private.h" + #include "database-private.h" + ++#include + #include + + #include +@@ -682,6 +683,8 @@ _notmuch_message_ensure_filename_list (notmuch_message_t *message) + const char *db_path, *directory, *basename, *filename; + char *colon, *direntry = NULL; + unsigned int directory_id; ++ UriUriA parsed; ++ UriParserStateA parser; + + direntry = node->string; + +@@ -700,9 +703,20 @@ _notmuch_message_ensure_filename_list (notmuch_message_t *message) + message->notmuch, + directory_id); + +- if (strlen (directory)) +- filename = talloc_asprintf (message, "%s/%s/%s", +- db_path, directory, basename); ++ parser.uri = &parsed; ++ ++ if (strlen (directory)) { ++ /* If directory is a URI, we don't need to append the db_path; ++ * it is already an absolute path. */ ++ if (uriParseUriA (&parser, directory) != URI_SUCCESS || ++ parsed.scheme.first == NULL) ++ filename = talloc_asprintf (message, "%s/%s/%s", ++ db_path, directory, basename); ++ else ++ filename = talloc_asprintf (message, "%s/%s", ++ directory, basename); ++ uriFreeUriMembersA (&parsed); ++ } + else + filename = talloc_asprintf (message, "%s/%s", + db_path, basename); +-- +1.7.9.5 + -- 2.26.2