X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fmessage.cc;h=b8128505bfb7c63176728bbe145b87113dd4c5a7;hp=ee52672a6ca5e1c1d514a31bb63271ac03725baa;hb=404db1de90f6e5a66c34077b38b18a39c955ece2;hpb=4b6063397ffcc13f38757e7052e3dc6649d9703c diff --git a/lib/message.cc b/lib/message.cc index ee52672a..b8128505 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -868,6 +868,7 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t *message) const char *filename; char *combined_flags = talloc_strdup (message, ""); unsigned i; + int seen_maildir_info = 0; for (filenames = notmuch_message_get_filenames (message); notmuch_filenames_valid (filenames); @@ -879,11 +880,18 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t *message) if (! flags) continue; + seen_maildir_info = 1; flags += 3; combined_flags = talloc_strdup_append (combined_flags, flags); } + /* If none of the filenames have any maildir info field (not even + * an empty info with no flags set) then there's no information to + * go on, so do nothing. */ + if (! seen_maildir_info) + return NOTMUCH_STATUS_SUCCESS; + status = notmuch_message_freeze (message); if (status) return status; @@ -998,14 +1006,19 @@ notmuch_message_tags_to_maildir_flags (notmuch_message_t *message) strcpy (filename_new+(p-filename)+3, flags); if (strcmp (filename, filename_new) != 0) { + notmuch_status_t status; + ret = rename (filename, filename_new); if (ret == -1) { perror (talloc_asprintf (message, "rename of %s to %s failed", filename, filename_new)); exit (1); } - return _notmuch_message_rename (message, filename_new); - /* _notmuch_message_sync is our caller. Do not call it here. */ + status = _notmuch_message_rename (message, filename_new); + + _notmuch_message_sync (message); + + return status; } return NOTMUCH_STATUS_SUCCESS; }