]> git.notmuchmail.org Git - notmuch/commitdiff
lib: Indicate whether notmuch_database_remove_message removed anything.
authorCarl Worth <cworth@cworth.org>
Wed, 6 Jan 2010 18:06:00 +0000 (10:06 -0800)
committerCarl Worth <cworth@cworth.org>
Wed, 6 Jan 2010 18:32:06 +0000 (10:32 -0800)
Similar to the return value of notmuch_database_add_message, we now
enhance the return value of notmuch_database_remove_message to
indicate whether the message document was entirely removed (SUCCESS)
or whether only this filename was removed and the document exists
under other filenamed (DUPLICATE_MESSAGE_ID).

lib/database.cc
lib/notmuch.h

index 205d0360e1c2f07c79cb29b28b82a442b40f2384..dc967c8c8ae62b65e25168747468a68d46c14d0e 100644 (file)
@@ -1201,14 +1201,16 @@ notmuch_database_remove_message (notmuch_database_t *notmuch,
            strncmp ((*j).c_str (), prefix, strlen (prefix)))
        {
            db->delete_document (document.get_docid ());
            strncmp ((*j).c_str (), prefix, strlen (prefix)))
        {
            db->delete_document (document.get_docid ());
+           status = NOTMUCH_STATUS_SUCCESS;
        } else {
            db->replace_document (document.get_docid (), document);
        } else {
            db->replace_document (document.get_docid (), document);
+           status = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;
        }
     }
 
     talloc_free (local);
 
        }
     }
 
     talloc_free (local);
 
-    return NOTMUCH_STATUS_SUCCESS;
+    return status;
 }
 
 notmuch_tags_t *
 }
 
 notmuch_tags_t *
index 52078e812a712101b355f012674f5acb5c129f98..110061c29ae62d37e8df2b53038980d2e3a76cea 100644 (file)
@@ -237,12 +237,21 @@ notmuch_database_add_message (notmuch_database_t *database,
 
 /* Remove a message from the given notmuch database.
  *
 
 /* Remove a message from the given notmuch database.
  *
- * Note that the only this particular filename association is removed
- * from the database. If the same message (as determined by the
- * message ID) is still available via other filenames, then the
- * message will persist in the database for those filenames. When the
- * last filename is removed for a particular message, the database
- * content for that message will be entirely removed.
+ * Note that only this particular filename association is removed from
+ * the database. If the same message (as determined by the message ID)
+ * is still available via other filenames, then the message will
+ * persist in the database for those filenames. When the last filename
+ * is removed for a particular message, the database content for that
+ * message will be entirely removed.
+ *
+ * Return value:
+ *
+ * NOTMUCH_STATUS_SUCCESS: The last filename was removed and the
+ *     message was removed from the database.
+ *
+ * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: This filename was removed but
+ *     the message persists in the database with at least one other
+ *     filename.
  */
 notmuch_status_t
 notmuch_database_remove_message (notmuch_database_t *database,
  */
 notmuch_status_t
 notmuch_database_remove_message (notmuch_database_t *database,