From 2ef9d3d8430276a6a3907d606e21621db723314f Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Wed, 1 Jan 2014 17:20:14 +0200 Subject: [PATCH] [PATCH 2/2] insert: respect maildir.synchronize_flags --- c5/3c9f54262a5d1c049cac94cd293603cb1497d5 | 164 ++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 c5/3c9f54262a5d1c049cac94cd293603cb1497d5 diff --git a/c5/3c9f54262a5d1c049cac94cd293603cb1497d5 b/c5/3c9f54262a5d1c049cac94cd293603cb1497d5 new file mode 100644 index 000000000..cf3b1d746 --- /dev/null +++ b/c5/3c9f54262a5d1c049cac94cd293603cb1497d5 @@ -0,0 +1,164 @@ +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 2D441431FCB + for ; Wed, 1 Jan 2014 07:20:27 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 lgO83u2RzkDi for ; + Wed, 1 Jan 2014 07:20:22 -0800 (PST) +Received: from mail-ea0-f175.google.com (mail-ea0-f175.google.com + [209.85.215.175]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 3E245431FC2 + for ; Wed, 1 Jan 2014 07:20:20 -0800 (PST) +Received: by mail-ea0-f175.google.com with SMTP id z10so5862824ead.6 + for ; Wed, 01 Jan 2014 07:20:19 -0800 (PST) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to + :references; + bh=MGz2lHZEQsnOpII6lA9P1bI3maRf6BCg2qvEQnVBWYk=; + b=Moob3M+DjYPBDjEOTsvkuSQGNGNztwdc4JJBB3yBYee051LH9neH3SQDl8dgYtkhDY + udaWyuq+T98U43ov6AaUGelF+McJYqg0gY6HEFSfktCOG8TXKRZOyI9m10F7+ZSJgJey + 6sTJZastCuXCV9zFd+Z3MXq7qH84+3HGIgm2Qs6DmPAZr+d7geVJcUTJSvmo4ygLWI+l + D5IgrSkvOvRSEv7/hWOTmT3nAkz1QtITTVu/3wRxi+SY2Xl7FUwkWbswoitrm1bZyKfT + 08m0HaUxJKaHhtxPfvir0eBQoBMio5Vamx321qH9EbtfHAVntXGN6/VVbC8SEJCFrC59 + EY3g== +X-Gm-Message-State: + ALoCoQn+dZKHcCLaF+/Lcy53R7RET/qvP6tGIa+NsBCi5UG/J9kKGA3T2+NriDYldnzMDruvkNDj +X-Received: by 10.14.205.201 with SMTP id j49mr11544528eeo.85.1388589619104; + Wed, 01 Jan 2014 07:20:19 -0800 (PST) +Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi. + [88.195.111.91]) by mx.google.com with ESMTPSA id + o1sm127844319eea.10.2014.01.01.07.20.17 for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Wed, 01 Jan 2014 07:20:18 -0800 (PST) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH 2/2] insert: respect maildir.synchronize_flags +Date: Wed, 1 Jan 2014 17:20:14 +0200 +Message-Id: <1388589614-19671-2-git-send-email-jani@nikula.org> +X-Mailer: git-send-email 1.8.5.2 +In-Reply-To: <1388589614-19671-1-git-send-email-jani@nikula.org> +References: <1388589614-19671-1-git-send-email-jani@nikula.org> +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 15:20:27 -0000 + +Don't synchronize maildir flags if the user doesn't want it. +--- + 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 + -- 2.26.2