unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 1/2] test: notmuch insert with maildir.synchronize_flags=false
@ 2014-01-01 15:20 Jani Nikula
  2014-01-01 15:20 ` [PATCH 2/2] insert: respect maildir.synchronize_flags Jani Nikula
  2014-01-03 11:33 ` [PATCH 1/2] test: notmuch insert with maildir.synchronize_flags=false David Bremner
  0 siblings, 2 replies; 5+ messages in thread
From: Jani Nikula @ 2014-01-01 15:20 UTC (permalink / raw)
  To: notmuch

Known broken, notmuch insert does not respect the config option.
---
 test/insert | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/test/insert b/test/insert
index 550b413..9283e70 100755
--- a/test/insert
+++ b/test/insert
@@ -113,6 +113,17 @@ output=$(notmuch search --output=files id:$gen_msg_id)
 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
+notmuch insert +flagged < "$gen_msg_filename"
+output=$(notmuch search --output=files id:$gen_msg_id)
+dirname=$(dirname "$output")
+notmuch config set maildir.synchronize_flags $OLDCONFIG
+test_expect_equal "$dirname" "$MAIL_DIR/new"
+
 test_begin_subtest "Insert message into folder"
 gen_insert_msg
 notmuch insert --folder=Drafts < "$gen_msg_filename"
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] insert: respect maildir.synchronize_flags
  2014-01-01 15:20 [PATCH 1/2] test: notmuch insert with maildir.synchronize_flags=false Jani Nikula
@ 2014-01-01 15:20 ` Jani Nikula
  2014-01-01 16:30   ` Tomi Ollila
  2014-01-01 19:25   ` Austin Clements
  2014-01-03 11:33 ` [PATCH 1/2] test: notmuch insert with maildir.synchronize_flags=false David Bremner
  1 sibling, 2 replies; 5+ messages in thread
From: Jani Nikula @ 2014-01-01 15:20 UTC (permalink / raw)
  To: notmuch

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, &notmuch))
 	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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] insert: respect maildir.synchronize_flags
  2014-01-01 15:20 ` [PATCH 2/2] insert: respect maildir.synchronize_flags Jani Nikula
@ 2014-01-01 16:30   ` Tomi Ollila
  2014-01-01 19:25   ` Austin Clements
  1 sibling, 0 replies; 5+ messages in thread
From: Tomi Ollila @ 2014-01-01 16:30 UTC (permalink / raw)
  To: Jani Nikula, notmuch

On Wed, Jan 01 2014, Jani Nikula <jani@nikula.org> 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, &notmuch))
>  	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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] insert: respect maildir.synchronize_flags
  2014-01-01 15:20 ` [PATCH 2/2] insert: respect maildir.synchronize_flags Jani Nikula
  2014-01-01 16:30   ` Tomi Ollila
@ 2014-01-01 19:25   ` Austin Clements
  1 sibling, 0 replies; 5+ messages in thread
From: Austin Clements @ 2014-01-01 19:25 UTC (permalink / raw)
  To: Jani Nikula; +Cc: notmuch

LGTM.

Quoth Jani Nikula on Jan 01 at  5:20 pm:
> Don't synchronize maildir flags if the user doesn't want it.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] test: notmuch insert with maildir.synchronize_flags=false
  2014-01-01 15:20 [PATCH 1/2] test: notmuch insert with maildir.synchronize_flags=false Jani Nikula
  2014-01-01 15:20 ` [PATCH 2/2] insert: respect maildir.synchronize_flags Jani Nikula
@ 2014-01-03 11:33 ` David Bremner
  1 sibling, 0 replies; 5+ messages in thread
From: David Bremner @ 2014-01-03 11:33 UTC (permalink / raw)
  To: Jani Nikula, notmuch

Jani Nikula <jani@nikula.org> writes:

> Known broken, notmuch insert does not respect the config option.

series pushed.

d

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-01-03 11:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-01 15:20 [PATCH 1/2] test: notmuch insert with maildir.synchronize_flags=false Jani Nikula
2014-01-01 15:20 ` [PATCH 2/2] insert: respect maildir.synchronize_flags Jani Nikula
2014-01-01 16:30   ` Tomi Ollila
2014-01-01 19:25   ` Austin Clements
2014-01-03 11:33 ` [PATCH 1/2] test: notmuch insert with maildir.synchronize_flags=false David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).