aboutsummaryrefslogtreecommitdiff
path: root/lib/message.cc
AgeCommit message (Collapse)Author
2010-01-06database: Abstract _filename_to_direntry from _add_messageCarl Worth
The code to map a filename to a direntry is something that we're going to want in a future _remove_message function, so put it in a new function _notmuch_database_filename_to_direntry .
2010-01-06database: Allowing storing multiple filenames for a single message ID.Carl Worth
The library interface is unchanged so far, (still just notmuch_database_add_message), but internally, the old _set_filename function is now _add_filename instead.
2010-01-06database: Store mail filename as a new 'direntry' term, not as 'data'.Carl Worth
Instead of storing the complete message filename in the data portion of a mail document we now store a 'direntry' term that contains the document ID of a directory document and also the basename of the message filename within that directory. This will allow us to easily store multple filenames for a single message, and will also allow us to find mail documents for files that previously existed in a directory but that have since been deleted.
2010-01-06lib: Abstract the extraction of a relative path from set_filenameCarl Worth
We'll soon be having multiple entry points that accept a filename path, so we want common code for getting a relative path from a potentially absolute path.
2009-11-28Avoid bogus internal error reporting duplicate In-Reply-To IDs.Carl Worth
This error was tirggered with a debugging build via: make CXXFLAGS="-DDEBUG" and reported by David Bremner. The actual error is that I'm an idiot that doesn't know how to use strcmp's return value. Of course, the strcmp interface scores a negative 7 on Rusty Russell ranking of bad interfaces: http://ozlabs.org/~rusty/index.cgi/tech/2008-04-01.html
2009-11-27add missing comma in debugging codeDavid Bremner
2009-11-27message: add flags to notmuch_message_tBart Trojanowski
This patch allows for different flags, internal to notmuch, to be set on a message object. The patch does not define any such flags, just the facilities to manage these flags. Signed-off-by: Bart Trojanowski <bart@jukie.net>
2009-11-26notmuch: New function to retrieve all tags from the database.Jan Janak
This patch adds a new function called notmuch_database_get_all_tags which can be used to obtain a list of all tags from the database (in other words, the list contains all tags from all messages). The function produces an alphabetically sorted list. To add support for the new function, we rip the guts off of notmuch_message_get_tags and put them in a new generic function called _notmuch_convert_tags. The generic function takes a Xapian::TermIterator as argument and uses the iterator to find tags. This makes the function usable with different Xapian objects. Function notmuch_message_get_tags is then reimplemented to call the generic function with message->doc.termlist_begin() as argument. Similarly, we implement notmuch_message_database_get_all_tags, the function calls the generic function with db->xapian_db->allterms_begin() as argument. Finally, notmuch_database_get_all_tags is exported through lib/notmuch.h Signed-off-by: Jan Janak <jan@ryngle.com>
2009-11-23fix notmuch-new bug when database path ends with a trailing /Bart Trojanowski
I configured my database.path with a trailing /, and after running notmuch new every notmuch search would fail with error messages like this: Error opening /inbox/cur/1258565257.000211.mbox:2,S: No such file or directory The actual bug was in the filename normalization for storage in the database. The database.path was removed from the full filename, but if the database.path from the config file contained a trailing /, the relative file name would retain an extra leading /... which made it look like an absolute path after it was read out from the DB. Signed-off-by: Bart Trojanowski <bart@jukie.net>
2009-11-22Catch and optionally print about exception at database->flush.Carl Worth
If an earlier exception occurred, then it's not unexpected for the flush to fail as well. So in that case, we'll silently catch the exception. Otherwise, make some noise about things going wrong at the time of flush.
2009-11-22Add a missing print after catching an exception.Carl Worth
Without this, trying to debug this exception was *really* confusing.
2009-11-21Rename NOTMUCH_DATABASE_MODE_WRITABLE to NOTMUCH_DATABASE_MODE_READ_WRITECarl Worth
And correspondingly, READONLY to READ_ONLY.
2009-11-21Permit opening the notmuch database in read-only mode.Chris Wilson
We only rarely need to actually open the database for writing, but we always create a Xapian::WritableDatabase. This has the effect of preventing searches and like whilst updating the index. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Acked-by: Carl Worth <cworth@cworth.org>
2009-11-20add_message: Re-fix handling of non-mail files.Carl Worth
More fallout from _get_header now returning "" for missing headers. The bug here is that we would no longer detect that a file is not an email message and give up on it like we should. And this time, I actually audited all callers to notmuch_message_get_header, so hopefully we're done fixing this bug over and over.
2009-11-20Avoid access of a Xapian iterator's object when there's nothing there.Carl Worth
This eliminates a crash when a message (either corrupted or a non-mail file that wasn't properly detected as not being mail) has no In-Reply-To header, (and so few terms that trying to skip to the prefix of the In-Reply-To terms actually brings us to the end of the termlist).
2009-11-18TypsosIngmar Vanhassel
2009-11-17Fix "too many open files" bug by closing message files when done with them.Keith Packard
The message file header parsing code parses only enough of the file to find the desired header fields, then it leaves the file open until the next header parsing call or when the message is no longer in use. If a large number of messages end up being active, this will quickly run out of file descriptors. Here, we add support to explicitly close the message file within a message, (_notmuch_message_close) and call that from thread construction code. Signed-off-by: Keith Packard <keithp@keithp.com> Edited-by: Carl Worth <cworth@cworth.org>: Many portions of Keith's original patch have since been solved other ways, (such as the code that changed the handling of the In-Reply-To header). So the final version is clean enough that I think even Keith would be happy to have his name on it.
2009-11-17message_get_thread_id: Generate internal error if message has no thread ID.Carl Worth
This case was happening when a message had its own message ID in its In-Reply-To header. The thread-resolution code would find the partially constructed message, (with no thread ID yet), get garbage from this function, and then march right along with that garbage. With this commit, a self-cyclic message like this will now trigger an internal error rather than marching along silienty. (And a subsequent commit will remove the call to this function in this case.)
2009-11-17Remove the talloc_owner argument from create_for_message_id.Carl Worth
This function has only one caller, and that one caller was passing the same value for both talloc_owner and the notmuch database. Dropping the redundant argument simplifies the documentation of this function considerably.
2009-11-17get_in_reply_to: Implement via the database, not by opening mail file.Carl Worth
This reduces our reliance on open message_file objects, (so is a step toward fixing the "too many open files" bug), but more importantly, it means we don't load a self-referencing in-reply-to header, (since we weed those out before adding any replyto terms to the database).
2009-11-17Include <stdint.h> to get uint32_t in C++ file with gcc 4.4Mikhail Gusarov
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
2009-11-15notmuch show: Implement proper thread ordering/nesting of messages.Carl Worth
We now properly analyze the in-reply-to headers to create a proper tree representing the actual thread and present the messages in this correct thread order. Also, there's a new "depth:" value added to the "message{" header so that clients can format the thread as desired, (such as by indenting replies).
2009-11-15Add _notmuch_message_get_in_reply_to.Carl Worth
The existing notmuch_message_get_header is *almost* good enough for this, except that we also need to remove the '<' and '>' delimiters. We'll probably want to implement this function with database storage in the future rather than loading the email message.
2009-11-09libify: Move library sources down into lib directory.Carl Worth
A "make" invocation still works from the top-level, but not from down inside the lib directory yet.