]> git.notmuchmail.org Git - notmuch/commitdiff
Fix notmuch_message_tags_to_maildir_flags to effect rename immediately
authorCarl Worth <cworth@cworth.org>
Thu, 11 Nov 2010 08:26:04 +0000 (00:26 -0800)
committerCarl Worth <cworth@cworth.org>
Thu, 11 Nov 2010 11:40:19 +0000 (03:40 -0800)
We have tests to ensure that when the notmuch library renames a file
that that rename takes place immediately in the database, (without
requiring something like "notmuch new" to notice the change).

This was working when the code was first added, but recently broke in
the reworking of the maildir-synchronization interface since the
tags_to_maildir_flags function can no longer assume that it is being
called as part of _notmuch_message_sync.

Fortunately, the fix is as simple as adding an explicit call to
_notmuch_message_sync.

lib/message.cc

index ee52672a6ca5e1c1d514a31bb63271ac03725baa..39036ecca5516a4a7bc6f896f686a62d89d503c6 100644 (file)
@@ -998,14 +998,19 @@ notmuch_message_tags_to_maildir_flags (notmuch_message_t *message)
     strcpy (filename_new+(p-filename)+3, flags);
 
     if (strcmp (filename, filename_new) != 0) {
     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);
        }
        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;
 }
     }
     return NOTMUCH_STATUS_SUCCESS;
 }