X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fmessage.cc;h=1b4637950f8e1a4475a4385db20fd6f4ccf7dd54;hp=c4261e614d4eb83b605bd2312cad727a57b9ab95;hb=8fb16e277e4d6c32bafa79ae7967e1e6ba9258e0;hpb=51b073c6f27f4439b2d003df1be1177365e555fe diff --git a/lib/message.cc b/lib/message.cc index c4261e61..1b463795 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -1195,7 +1195,9 @@ _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", except for the case when + * no flags are changed and the existing filename does not contain + * maildir info (starting with ",2:"). * * After a sequence of ":2," in the filename, any subsequent * single-character flags will be added or removed according to the @@ -1218,6 +1220,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; @@ -1258,6 +1261,7 @@ _new_maildir_filename (void *ctx, if (flag_map[flag] == 0) { flag_map[flag] = 1; flags_in_map++; + flags_changed = TRUE; } } @@ -1266,9 +1270,16 @@ _new_maildir_filename (void *ctx, if (flag_map[flag]) { flag_map[flag] = 0; flags_in_map--; + flags_changed = TRUE; } } + /* Messages in new/ without maildir info can be kept in new/ if no + * flags have changed. */ + dir = (char *) _filename_is_in_maildir (filename); + if (dir && STRNCMP_LITERAL (dir, "new/") == 0 && !*info && !flags_changed) + return talloc_strdup (ctx, filename); + filename_new = (char *) talloc_size (ctx, info - filename + strlen (":2,") + flags_in_map + 1);