/* Ignore failure to remove non-existent term. */
}
}
+
+ _notmuch_message_invalidate_metadata (message, "property");
}
}
/* Add "folder:" term for directory. */
-static notmuch_status_t
+NODISCARD static notmuch_status_t
_notmuch_message_add_folder_terms (notmuch_message_t *message,
const char *directory)
{
#define RECURSIVE_SUFFIX "/**"
/* Add "path:" terms for directory. */
-static notmuch_status_t
+NODISCARD static notmuch_status_t
_notmuch_message_add_path_terms (notmuch_message_t *message,
const char *directory)
{
const char *direntry, *directory;
char *colon;
const std::string &term = *i;
+ notmuch_status_t term_status;
/* Terminate loop at first term without desired prefix. */
if (strncmp (term.c_str (), direntry_prefix, direntry_prefix_len))
message->notmuch,
directory_id);
- _notmuch_message_add_folder_terms (message, directory);
- _notmuch_message_add_path_terms (message, directory);
+ term_status = _notmuch_message_add_folder_terms (message, directory);
+ if (term_status)
+ return term_status;
+
+ term_status = _notmuch_message_add_path_terms (message, directory);
+ if (term_status)
+ return term_status;
}
return status;
{
const char *relative, *directory;
notmuch_status_t status;
+ notmuch_private_status_t private_status;
void *local = talloc_new (message);
char *direntry;
/* New file-direntry allows navigating to this message with
* notmuch_directory_get_child_files() . */
- status = COERCE_STATUS (_notmuch_message_add_term (message, "file-direntry", direntry),
- "adding file-direntry term");
+ private_status = _notmuch_message_add_term (message, "file-direntry", direntry);
+ switch (private_status) {
+ case NOTMUCH_PRIVATE_STATUS_SUCCESS:
+ break;
+ case NOTMUCH_PRIVATE_STATUS_TERM_TOO_LONG:
+ _notmuch_database_log (message->notmuch, "filename too long for file-direntry term: %s\n",
+ filename);
+ return NOTMUCH_STATUS_PATH_ERROR;
+ default:
+ return COERCE_STATUS (private_status, "adding file-direntry term");
+ }
+
+ status = _notmuch_message_add_folder_terms (message, directory);
if (status)
return status;
- _notmuch_message_add_folder_terms (message, directory);
- _notmuch_message_add_path_terms (message, directory);
+ status = _notmuch_message_add_path_terms (message, directory);
+ if (status)
+ return status;
talloc_free (local);
if (status)
return status;
- message->notmuch->writable_xapian_db->delete_document (message->doc_id);
-
- /* if this was a ghost to begin with, we are done */
- private_status = _notmuch_message_has_term (message, "type", "ghost", &is_ghost);
- if (private_status)
- return COERCE_STATUS (private_status,
- "Error trying to determine whether message was a ghost");
- if (is_ghost)
- return NOTMUCH_STATUS_SUCCESS;
-
- /* look for a non-ghost message in the same thread */
try {
Xapian::PostingIterator thread_doc, thread_doc_end;
Xapian::PostingIterator mail_doc, mail_doc_end;
+ /* look for a non-ghost message in the same thread */
+ /* if this was a ghost to begin with, we are done */
+ private_status = _notmuch_message_has_term (message, "type", "ghost", &is_ghost);
+ if (private_status)
+ return COERCE_STATUS (private_status,
+ "Error trying to determine whether message was a ghost");
+
+ message->notmuch->writable_xapian_db->delete_document (message->doc_id);
+
+ if (is_ghost)
+ return NOTMUCH_STATUS_SUCCESS;
+
_notmuch_database_find_doc_ids (message->notmuch, "thread", tid, &thread_doc,
&thread_doc_end);
_notmuch_database_find_doc_ids (message->notmuch, "type", "mail", &mail_doc, &mail_doc_end);
char *to_set, *to_clear;
notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
+ status = _notmuch_database_ensure_writable (message->notmuch);
+ if (status)
+ return status;
+
_get_maildir_flag_actions (message, &to_set, &to_clear);
for (filenames = notmuch_message_get_filenames (message);