From: Ethan Glasser-Camp Date: Mon, 25 Jun 2012 20:51:48 +0000 (+2000) Subject: [RFC PATCH 05/14] new: use new URL-based filenames for messages X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=7edb6b08ae1bcf393cf3c9a5b90de2046e20fc9b;p=notmuch-archives.git [RFC PATCH 05/14] new: use new URL-based filenames for messages --- diff --git a/8f/3cc06c129d60af52caf88f7134890f0eb374a7 b/8f/3cc06c129d60af52caf88f7134890f0eb374a7 new file mode 100644 index 000000000..c42339df9 --- /dev/null +++ b/8f/3cc06c129d60af52caf88f7134890f0eb374a7 @@ -0,0 +1,160 @@ +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 3D9C5431FB6 + for ; Mon, 25 Jun 2012 13:52:27 -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 AIR-5bzUUieL for ; + Mon, 25 Jun 2012 13:52:25 -0700 (PDT) +Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com + [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 5396F431FAF for ; Mon, 25 Jun 2012 13:52:25 -0700 + (PDT) +Received: by wgbdt14 with SMTP id dt14so3709395wgb.2 + for ; Mon, 25 Jun 2012 13:52:24 -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; + bh=YqK8BU9axMj+Rr5tO1sFHtUxlwDAX28vQ9xpC//GUDw=; + b=CGevjzK+6x+1hcxjFEcIbktSvOK62V5PAqbXTAPDZippKuVfUj2vA6sLFhvHDsywMo + 4xBcKCcuGVuZFwhwpGNZx+kRVu53CswPa9rjhD8YmWjqZpTPjTDZG2cWY5Cvg+BVBVuY + lNgrEijURGjSDWoQ/RBMj7wPhsyGcluvVyOvA65UsTMhTkTpaCzqkBJR72QfxTQJCfza + pSLVeqO1saQJBx9kzKE/012sG6vr5DMDyMuZk3nu10QUMOr/2NzVhRmlZs/iSHd9bvXW + CtCTX8JHInzrLVZRqV5G5ro5FqTXV0a3qHcFdreGAxL0mrtqqkW7Bq9OTfYl+03MP1Uh + S4Ow== +Received: by 10.180.83.197 with SMTP id s5mr27227608wiy.9.1340657544059; + Mon, 25 Jun 2012 13:52:24 -0700 (PDT) +Received: from localhost ([195.24.209.21]) + by mx.google.com with ESMTPS id f7sm77266wiv.2.2012.06.25.13.52.18 + (version=TLSv1/SSLv3 cipher=OTHER); + Mon, 25 Jun 2012 13:52:23 -0700 (PDT) +From: Ethan Glasser-Camp +To: notmuch@notmuchmail.org +Subject: [RFC PATCH 05/14] new: use new URL-based filenames for messages +Date: Mon, 25 Jun 2012 16:51:48 -0400 +Message-Id: <1340657517-6539-1-git-send-email-ethan@betacantrips.com> +X-Mailer: git-send-email 1.7.9.5 +X-Mailman-Approved-At: Tue, 26 Jun 2012 03:51:54 -0700 +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: Mon, 25 Jun 2012 20:52:27 -0000 + +This commit breaks a bunch of tests; fixes follow. + +Signed-off-by: Ethan Glasser-Camp +--- + 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 +