unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 0/4 v4] lib: Maildir flags synchronization fixes
@ 2011-09-14 22:23 Louis Rilling
  2011-09-14 22:23 ` [PATCH 1/4] lib: Kill last usage of C++ type bool Louis Rilling
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Louis Rilling @ 2011-09-14 22:23 UTC (permalink / raw)
  To: notmuch; +Cc: Michal Sojka, Austin Clements

Hello,

Here is the updated series of fixes I have around maildir flags
synchronization. The first two patches are just cleanups that can be applied
independently.

The intent for the fourth patch (detailed in the commit log) is to allow mutt
users to keep using the "new" status, as long as notmuch can respect the
maildir specification.

The third patch implements a test for the new desired behavior. From recent
discussions I decided to put it before the actual changes, but it certainly can
move after if this is preferred.

Changelog:
* v4: 
 - rebased on top of release 0.8
 - included the test contributed by Michal Sojka
* v3: Added patch to kill the last usage of C++ type bool
* v2: Fix bool type as well as NULL returned despite having no errors (Austin
      Clements)

Thanks,

Louis


Louis Rilling (3):
      lib: Kill last usage of C++ type bool
      tags_to_maildir_flags: Cleanup double assignement
      tags_to_maildir_flags: Don't rename if no flags change

Michal Sojka (1):
      test: Adding non-maildir tags does not move message from new to cur

 lib/message.cc    |   26 +++++++++++++++++---------
 test/maildir-sync |    6 ++++++
 2 files changed, 23 insertions(+), 9 deletions(-)

^ permalink raw reply	[flat|nested] 14+ messages in thread
* [PATCH 3/3] tags_to_maildir_flags: Don't rename if no flags change
@ 2011-07-12 13:59 Louis Rilling
  2011-07-14  0:06 ` [PATCH] test: Adding non-maildir tags does not move message from new to cur Michal Sojka
  0 siblings, 1 reply; 14+ messages in thread
From: Louis Rilling @ 2011-07-12 13:59 UTC (permalink / raw)
  To: Carl Worth; +Cc: notmuch, Austin Clements

notmuch_message_tags_to_maildir_flags() unconditionally moves messages from
maildir directory "new/" to maildir directory "cur/", which makes messages lose
their "new" status in the MUA. However some users want to keep this "new"
status after, for instance, an auto-tagging of new messages.

However, as Austin mentioned and according to the maildir specification,
messages living in "new/" are not allowed to have flags, even if mutt allows it
to happen. For this reason, this patch prevents moving messages from "new/" to
"cur/", only if no flags have to be changed. It's hopefully enough to satisfy
mutt (and maybe other MUAs showing the "new" status) users checking the "new"
status.

Changelog:
* v2: Fix bool type as well as NULL returned despite having no errors (Austin
      Clements)

Signed-off-by: Louis Rilling <l.rilling@av7.net>
---
 lib/message.cc |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/lib/message.cc b/lib/message.cc
index b1b2942..c003729 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -1139,7 +1139,7 @@ _get_maildir_flag_actions (notmuch_message_t *message,
  * compute the new maildir filename.
  *
  * If the existing filename is in the directory "new", the new
- * filename will be in the directory "cur".
+ * filename will be in the directory "cur", unless no flags are changed.
  *
  * After a sequence of ":2," in the filename, any subsequent
  * single-character flags will be added or removed according to the
@@ -1162,6 +1162,7 @@ _new_maildir_filename (void *ctx,
     char *filename_new, *dir;
     char flag_map[128];
     int flags_in_map = 0;
+    notmuch_bool_t flags_changed = FALSE;
     unsigned int i;
     char *s;
 
@@ -1202,6 +1203,7 @@ _new_maildir_filename (void *ctx,
 	if (flag_map[flag] == 0) {
 	    flag_map[flag] = 1;
 	    flags_in_map++;
+	    flags_changed = TRUE;
 	}
     }
 
@@ -1210,9 +1212,17 @@ _new_maildir_filename (void *ctx,
 	if (flag_map[flag]) {
 	    flag_map[flag] = 0;
 	    flags_in_map--;
+	    flags_changed = TRUE;
 	}
     }
 
+    /* No need to rename. Messages in new/ can be kept in new/.
+     * Note: We don't even try to fix buggy messages having flags and living in
+     * new/. It's not our business.
+     */
+    if (!flags_changed)
+	return talloc_strdup (ctx, filename);
+
     filename_new = (char *) talloc_size (ctx,
 					 info - filename +
 					 strlen (":2,") + flags_in_map + 1);
-- 
1.7.2.5

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

end of thread, other threads:[~2012-12-19 21:39 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-14 22:23 [PATCH 0/4 v4] lib: Maildir flags synchronization fixes Louis Rilling
2011-09-14 22:23 ` [PATCH 1/4] lib: Kill last usage of C++ type bool Louis Rilling
2011-09-14 22:23 ` [PATCH 2/4] tags_to_maildir_flags: Cleanup double assignement Louis Rilling
2011-11-22  0:41   ` David Bremner
2011-09-14 22:23 ` [PATCH 3/4] test: Adding non-maildir tags does not move message from new to cur Louis Rilling
2011-09-14 22:23 ` [PATCH 4/4] tags_to_maildir_flags: Don't rename if no flags change Louis Rilling
2012-12-08 19:15   ` [PATCH] test: Adding non-maildir tags does not move message from new to cur david
2012-12-08 22:14     ` Jani Nikula
2012-12-19 21:39       ` Michal Sojka
2012-11-06  0:16 ` [PATCH 0/4 v4] lib: Maildir flags synchronization fixes Daniel
2012-11-06  2:16   ` David Bremner
2012-11-06 13:35     ` Daniel
  -- strict thread matches above, loose matches on Subject: below --
2011-07-12 13:59 [PATCH 3/3] tags_to_maildir_flags: Don't rename if no flags change Louis Rilling
2011-07-14  0:06 ` [PATCH] test: Adding non-maildir tags does not move message from new to cur Michal Sojka
2011-07-14 14:11   ` Louis Rilling

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).