From: Tomi Ollila Date: Wed, 1 Jan 2014 16:30:35 +0000 (+0200) Subject: Re: [PATCH 2/2] insert: respect maildir.synchronize_flags X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1bcf8eb75d296277c3c110306f221666b740e1be;p=notmuch-archives.git Re: [PATCH 2/2] insert: respect maildir.synchronize_flags --- diff --git a/10/137b661ec401d3c0ef3e88da8be36c912944a9 b/10/137b661ec401d3c0ef3e88da8be36c912944a9 new file mode 100644 index 000000000..0ba81148e --- /dev/null +++ b/10/137b661ec401d3c0ef3e88da8be36c912944a9 @@ -0,0 +1,162 @@ +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 1127C431FC0 + for ; Wed, 1 Jan 2014 08:30:51 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + 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 0RBL7aHw0V9W for ; + Wed, 1 Jan 2014 08:30:43 -0800 (PST) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id 5DFA7431FAF + for ; Wed, 1 Jan 2014 08:30:43 -0800 (PST) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id A63801000B2; + Wed, 1 Jan 2014 18:30:35 +0200 (EET) +From: Tomi Ollila +To: Jani Nikula , notmuch@notmuchmail.org +Subject: Re: [PATCH 2/2] insert: respect maildir.synchronize_flags +In-Reply-To: <1388589614-19671-2-git-send-email-jani@nikula.org> +References: <1388589614-19671-1-git-send-email-jani@nikula.org> + <1388589614-19671-2-git-send-email-jani@nikula.org> +User-Agent: Notmuch/0.17+13~gdfcf116 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +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: Wed, 01 Jan 2014 16:30:51 -0000 + +On Wed, Jan 01 2014, Jani Nikula wrote: + +> Don't synchronize maildir flags if the user doesn't want it. +> --- + +Looks good, tests pass. + +Tomi + + +> notmuch-insert.c | 24 ++++++++++++++++-------- +> test/insert | 1 - +> 2 files changed, 16 insertions(+), 9 deletions(-) +> +> diff --git a/notmuch-insert.c b/notmuch-insert.c +> index 2207b1e..55384e3 100644 +> --- a/notmuch-insert.c +> +++ b/notmuch-insert.c +> @@ -295,7 +295,7 @@ copy_stdin (int fdin, int fdout) +> * The file is renamed to encode notmuch tags as maildir flags. */ +> static void +> add_file_to_database (notmuch_database_t *notmuch, const char *path, +> - tag_op_list_t *tag_ops) +> + tag_op_list_t *tag_ops, notmuch_bool_t synchronize_flags) +> { +> notmuch_message_t *message; +> notmuch_status_t status; +> @@ -323,11 +323,15 @@ add_file_to_database (notmuch_database_t *notmuch, const char *path, +> +> if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) { +> /* Don't change tags of an existing message. */ +> - status = notmuch_message_tags_to_maildir_flags (message); +> - if (status != NOTMUCH_STATUS_SUCCESS) +> - fprintf (stderr, "Error: failed to sync tags to maildir flags\n"); +> + if (synchronize_flags) { +> + status = notmuch_message_tags_to_maildir_flags (message); +> + if (status != NOTMUCH_STATUS_SUCCESS) +> + fprintf (stderr, "Error: failed to sync tags to maildir flags\n"); +> + } +> } else { +> - tag_op_list_apply (message, tag_ops, TAG_FLAG_MAILDIR_SYNC); +> + tag_op_flag_t flags = synchronize_flags ? TAG_FLAG_MAILDIR_SYNC : 0; +> + +> + tag_op_list_apply (message, tag_ops, flags); +> } +> +> notmuch_message_destroy (message); +> @@ -335,7 +339,8 @@ add_file_to_database (notmuch_database_t *notmuch, const char *path, +> +> static notmuch_bool_t +> insert_message (void *ctx, notmuch_database_t *notmuch, int fdin, +> - const char *dir, tag_op_list_t *tag_ops) +> + const char *dir, tag_op_list_t *tag_ops, +> + notmuch_bool_t synchronize_flags) +> { +> char *tmppath; +> char *newpath; +> @@ -377,7 +382,7 @@ insert_message (void *ctx, notmuch_database_t *notmuch, int fdin, +> +> /* Even if adding the message to the notmuch database fails, +> * the message is on disk and we consider the delivery completed. */ +> - add_file_to_database (notmuch, newpath, tag_ops); +> + add_file_to_database (notmuch, newpath, tag_ops, synchronize_flags); +> +> return TRUE; +> +> @@ -400,6 +405,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[]) +> char *query_string = NULL; +> const char *folder = NULL; +> notmuch_bool_t create_folder = FALSE; +> + notmuch_bool_t synchronize_flags; +> const char *maildir; +> int opt_index; +> unsigned int i; +> @@ -420,6 +426,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[]) +> +> db_path = notmuch_config_get_database_path (config); +> new_tags = notmuch_config_get_new_tags (config, &new_tags_length); +> + synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config); +> +> tag_ops = tag_op_list_create (config); +> if (tag_ops == NULL) { +> @@ -471,7 +478,8 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[]) +> NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much)) +> return 1; +> +> - ret = insert_message (config, notmuch, STDIN_FILENO, maildir, tag_ops); +> + ret = insert_message (config, notmuch, STDIN_FILENO, maildir, tag_ops, +> + synchronize_flags); +> +> notmuch_database_destroy (notmuch); +> +> diff --git a/test/insert b/test/insert +> index 9283e70..e8dc4c0 100755 +> --- a/test/insert +> +++ b/test/insert +> @@ -114,7 +114,6 @@ dirname=$(dirname "$output") +> test_expect_equal "$dirname" "$MAIL_DIR/cur" +> +> test_begin_subtest "Insert message with maildir sync off goes to new/" +> -test_subtest_known_broken +> OLDCONFIG=$(notmuch config get maildir.synchronize_flags) +> notmuch config set maildir.synchronize_flags false +> gen_insert_msg +> -- +> 1.8.5.2 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch