aboutsummaryrefslogtreecommitdiffhomepage
path: root/database.cc
Commit message (Collapse)AuthorAge
*-. Merge branch from fixing up bugs after bisecting.Gravatar Carl Worth2009-10-21
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'm glad that when I implemented "notmuch restore" I went through the extra effort to take the code I had written in one sitting into over a dozen commits. Sure enough, I hadn't tested well enough and had totally broken "notmuch setup", (segfaults and bogus thread_id values). With the little commits I had made, git bisect saved the day, and I went back to make the fixes right on top of the commits that introduced the bugs. So now we octopus merge those in.
| | * Bring back the insert_thread_id function.Gravatar Carl Worth2009-10-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We deleted this in favor of our fancy new thread_ids iterator from the message object. But one of the previous callers of insert_thread_id isn't using notmuch_message_t yet. I made the mistake of thinking I could just call g_hash_table_insert directly, but the problem was that nobody was splitting up the thread_id string at its commas. So with this, we were inserting bogus comma-separated IDs into the hash table, so thread_id values were ballooning out of control. Should be much better now.
* | | Add notmuch_status_to_string function.Gravatar Carl Worth2009-10-21
| | | | | | | | | | | | | | | Be kind and let the user print error messages, not just error codes.
* | | Add notmuch_message_add_tag and notmuch_message_remove_tagGravatar Carl Worth2009-10-21
| |/ |/| | | | | | | With these two added, we now have enough functionality in the library to implement "notmuch restore".
* | database: Add new notmuch_database_find_messageGravatar Carl Worth2009-10-21
|/ | | | | | | With this function, and the recently added support for notmuch_message_get_thread_ids, we now recode the find_thread_ids function to work just the way we expect a user of the public notmuch API to work. Not too bad really.
* Rename NOTMUCH_MAX_TERM to NOTMUCH_TERM_MAXGravatar Carl Worth2009-10-21
| | | | Just better consistency with our naming schemes.
* Move find_prefix function from database.cc to message.ccGravatar Carl Worth2009-10-21
| | | | | | It's definitely a better fit there for now, (and can likely eventually be made static as add_term moves from database to message as well).
* Convert notmuch_database_t to start using talloc.Gravatar Carl Worth2009-10-21
| | | | | This will be handy as we can hang future talloc allocations off of the datbase now.
* notmuch setup: Collapse internal whitespace within message-idGravatar Carl Worth2009-10-21
| | | | | | | I'm too lazy to see what the RFC says, but I know that having whitespace inside a message-ID is sure to confuse things. And besides, this makes things more compatible with sup so that I have some hope of importing sup labels.
* notmuch dump: Fix the sorting of results.Gravatar Carl Worth2009-10-21
| | | | | | | | | | | | | To properly support sorting in notmuch_query we know use an Enquire object. We also throw in a QueryParser too, so we're really close to being able to support arbitrary full-text searches. I took a look at the supported QueryParser syntax and chose a set of flags for everything I like, (such as supporting Boolean operators in either case ("AND" or "and"), supporting phrase searching, supporting + and - to include/preclude terms, and supporting a trailing * on any term as a wildcard).
* add_message: Add a type:mail ("Kmail") term to all documents.Gravatar Carl Worth2009-10-21
| | | | | This gives us an easy way to specify "all mail messages" in a search query. We simply look for this term.
* database: Remove two little bits of dead code.Gravatar Carl Worth2009-10-20
|
* Implement 'notmuch dump'.Gravatar Carl Worth2009-10-20
| | | | | | | | | | | | | | | | This is a fairly big milestone for notmuch. It's our first command to do anything besides building the index, so it proves we can actually read valid results out from the index. It also puts in place almost all of the API and infrastructure we will need to allow searching of the database. Finally, with this change we are now using talloc inside of notmuch which is truly a delight to use. And now that I figured out how to use C++ objects with talloc allocation, (it requires grotty parts of C++ such as "placement new" and "explicit destructors"), we are valgrind-clean for "notmuch dump", (as in "no leaks are possible").
* Rename private notmuch_message_t to notmuch_message_file_tGravatar Carl Worth2009-10-20
| | | | | | | | | This is in preparation for a new, public notmuch_message_t. Eventually, the public notmuch_message_t is going to grow enough features to need to be file-backed and will likely need everything that's now in message-file.c. So we may fold these back into one object/implementation in the future.
* add_message: Fix memory leak of thread_ids GPtrArray.Gravatar Carl Worth2009-10-20
| | | | | | | | | We were properly feeing this memory when the thread-ids list was not empty, but leaking it when it was. Thanks, of course, to valgrind along with the G_SLICE=always-malloc environment variable which makes leak checking with glib almost bearable.
* database.cc: Document better pieces of glib that we're using.Gravatar Carl Worth2009-10-20
|
* notmuch_database_open: Fix error message for file-not-found.Gravatar Carl Worth2009-10-20
| | | | | | | | | I was incorrectly using the return value of stat (-1) instead of errno (ENOENT) to try to construct the error message here. Also, while we're here, reword the error message to not have "stat" in it, which in spite of what a Unix programmer will tell you, is not actually a word.
* notmuch_database_create/open: Fix to handle NULL as documented.Gravatar Carl Worth2009-10-20
| | | | | | | | | | | When documenting these functions I described support for a NOTMUCH_BASE environment variable to be consulted in the case of a NULL path. Only, I had forgotten to actually write the code. This code exists now, with a new, exported function: notmuch_database_default_path
* notmuch: Ignore files that don't look like email messages.Gravatar Carl Worth2009-10-19
| | | | | | | This is helpful for things like indexes that other mail programs may have left around. It also means we can make the initial instructions much easier, (the user need not worry about moving away auxiliary files from some other email program).
* Don't hash headers we won't end up using.Gravatar Carl Worth2009-10-19
| | | | Just saving a little work here.
* Document which pieces of glib we're still using.Gravatar Carl Worth2009-10-19
| | | | | | | | Looks like we can copy in a hash-table implementation, (from cairo, say), and then a few _ascii_ functions from glib, (we'll need to switch a few current uses if things like isspace, etc. to locale- independent versions as well). So not too hard to free ourselves of glib for now, (until we add GMime back in later, of course).
* Hook up our fancy new notmuch_parse_date function.Gravatar Carl Worth2009-10-19
| | | | | With all the de-glib-ification out of the way, we can now use it to allow for date-based sorting of Xapian search results.
* notmuch: Switch from gmime to custom, ad-hoc parsing of headers.Gravatar Carl Worth2009-10-19
| | | | | | | | | | | Since we're currently just trying to stitch together In-Reply-To and References headers we don't need that much sophistication. It's when we later add full-text searching that GMime will be useful. So for now, even though my own code here is surely very buggy compared to GMime it's also a lot faster. And speed is what we're after for the initial index creation.
* notmuch: Start actually adding messages to the index.Gravatar Carl Worth2009-10-18
This is the beginning of the notmuch library as well, with its interface in notmuch.h. So far we've got create, open, close, and add_message (all with a notmuch_database prefix). The current add_message function has already been whittled down from what we have in notmuch-index-message to add only references, message-id, and thread-id to the index, (that is---just enough to do thread-linkage but nothing for full-text searching). The concept here is to do something quickly so that the user can get some data into notmuch and start using it. (The most interesting stuff is then thread-linkage and labels like inbox and unread.) We can defer the full-text indexing of the body of the messages for later, (such as in the background while the user is reading mail). The initial thread-stitching step is still slower than I would like. We may have to stop using libgmime for this step as its overhead is not worth it for the simple case of just parsing the message-id, references, and in-reply-to headers.