aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2010-01-07lib: Clarify internal documentation of _notmuch_database_filename_to_direntryCarl Worth
The original wording made it sound like this function was just doing some string manipulation. But this function actually creates new directory documents as a side effect. So make that explicit in its documentation.
2010-01-07notmuch_message_get_filename: Support old-style filename storage.Carl Worth
When a notmuch database is upgraded to the new database format, (to support file rename and deletion), any message documents corresponding to deleted files will not currently be upgraded. This means that a search matching these documents will find no filenames in the expected place. Go ahead and return the filename as originally stored, (rather than aborting with an internal error), in this case.
2010-01-06lib: Treat NULL as a valid (and empty) notmuch_filenames_t iterator.Carl Worth
This will be convenient to avoid some special-casing in higher-level code.
2010-01-06lib: Indicate whether notmuch_database_remove_message removed anything.Carl Worth
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).
2010-01-06lib: Update documentation of notmuch_database_add_message.Carl Worth
Previously, adding a filename with the same message ID as an existing message would do nothing. But we recently fixed this to instead add the new filename to the existing message document. So update the documentation to match now.
2010-01-06Index content from citations and signatures.Carl Worth
In the presentation we often omit citations and signatures, but this is not content that should be omitted from the index, (especially when the citation detection is wrong---see cases where a line beginning with "From" is corrupted to ">From" by mail processing tools).
2010-01-06Makefiles: Use .DEFAULT to support arbitrary targets from sub directories.Carl Worth
Taking advantage of the .DEFAULT construct means that we won't need to explicitly list targets such as "clean", etc. in each sub-Makefile.
2010-01-06Add missing comment for NOTMUCH_STATUS_READONLY_DATABASE.Carl Worth
And adjust the string representation of the same to match.
2010-01-06lib: Implement new notmuch_directory_t API.Carl Worth
This new directory ojbect provides all the infrastructure needed to detect when files or directories are deleted or renamed. There's still code needed on top of this (within "notmuch new") to actually do that detection.
2010-01-06Revamp the proposed directory-tracking API slightly.Carl Worth
This commit contains my changes to the API proposed by Keith. Nothing is dramatically different. There are minor things like changing notmuch_files_t to notmuch_filenames_t and then various things needed for completeness as noticed while implementing this, (such as notmuch_directory_destroy and notmuch_directory_set_mtime).
2010-01-06Prototypes for directory trackingKeith Packard
There's no functionality here yet---just a sketch of what the interface could look like.
2010-01-06database: Add new, public notmuch_database_remove_messageCarl Worth
This will allow applications to support the removal of messages, (such as when a file is deleted from the mail store). No removal support is provided yet in commands such as "notmuch new".
2010-01-06database: Add new find_doc_ids_for_term interface.Carl Worth
The existing find_doc_ids function is convenient when the caller doesn't want to be bothered constructing a term. But when the caller *does* have the term already, that interface is just wasteful. So we export a lower-level interface that maps a pre-constructed term to a document-ID iterators.
2010-01-06database: Make find_unique_doc_id enforce uniqueness (for a debug build)Carl Worth
Catching any violation of this unique-ness constraint is very much in line with similar, existing INTERNAL_ERROR cases.
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-06database: Split _find_parent_id into _split_path and _find_directory_idCarl Worth
Some pending commits want the _split_path functionality separate from mapping a directory to a document ID. The split_path function now returns the basename as well as the directory name.
2010-01-06database: Store directory path in 'data' of directory documents.Carl Worth
We're planning to have mail documents refer to directory documents for the path of the containing directory. To support this, we need the path in the data, (since the path in the 'directory' term can be irretrievable as it will be the SHA1 sum of the path for a very long path).
2010-01-06database: Export _notmuch_database_find_parent_id for internal use.Carl Worth
We'll soon have mail documents referring to their parent directory's directory documents, so we'll need access to _find_parent_id in files such as message.cc.
2010-01-06database: Store the parent ID for each directory document.Carl Worth
Storing the document ID of the parent of each directory document will allow us to find all child-directory documents for a given directory document. We will need this in order to detect directories that have been removed from the mail store, (though we aren't yet doing this).
2010-01-06database: Rename internal directory value from XTIMESTAMP to XDIRECTORY.Carl Worth
The recent change from storing absolute paths to relative paths means that new directory documents will already be created, (and the old ones will just linger stale in the database). Given that, we might as well put a clean name on the term in the new documents, (and no real flag day is needed).
2010-01-06database: Store directory paths as relative, not absolute.Carl Worth
We were already storing relative mail filenames, so this is consistent with that. Additionally, it means that directory documents remain valid even if the database is relocated within its containing filesystem.
2010-01-06lib: Document that the filename is stored in the 'data' of a mail documentCarl Worth
Our database schema documentation previously didn't give any indication of where this most essential piece of information is stored.
2010-01-06lib: Rename set/get_timestamp to set/get_directory_mtime.Carl Worth
I've been suitably scolded by Keith for doing a premature generalization that ended up just making the documentation more convoluted. Fix that.
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.
2010-01-06lib: Add missing value to notmuch_private_status_t enum.Carl Worth
And fix the initialization such that the private enum will always have distinct values from the public enum even if we similarly miss the addition of a new public value in the future.
2009-12-09Nuke the remainings of _notmuch_message_add_thread_id.Fernando Carrijo
The function _notmuch_message_add_thread_id has been removed from the private interface of notmuch. There's no reason for one to keep a declaration of its prototype in the code base. Also, lets update a commentary that referenced that function and escaped from previous scrutiny. Signed-off-by: Fernando Carrijo <fcarrijo@yahoo.com.br>
2009-12-03Remove unused notmuch_parse_date function prototype.Jeffrey C. Ollie
notmuch_parse_date is not implemented, so remove the unused function prototype. Signed-off-by: Jeffrey C. Ollie <jeff@ocjtech.us>
2009-12-01Makefile: Incorporate getline implementation into the build.Carl Worth
It's unconditional for a very short time. We expect to soon be building it only if necessary.
2009-12-01xutil: Implement xstrndup without relying on strndup.Carl Worth
Since we need to do this for portability, (some systems don't have a strndup function), we might as well do it unconditionally. There's almost no disadvantage to doing so, and this has the advantages of not requiring a configure-time check nor having two different implementations, one of which would often be less tested.
2009-12-01lib/index: Fix memory leak for email addresses without names.Carl Worth
We carefully noted the fact that we had locally allocated the string here, but then we neglected to free it. Switch to talloc instead which makes it easier to get the behavior we want. It's simpler since we can just call talloc_free unconditionally, without having to track the state of whether we allocated the storage for name or not.
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-27correct message flag enum value so that it matches the typeBart Trojanowski
As per Carl's request, this patch corrects the only value defined under the notmuch_message_flag_t enum typedef to match the name of the type. Signed-off-by: Bart Trojanowski <bart@jukie.net>
2009-11-27add missing comma in debugging codeDavid Bremner
2009-11-27Silence compiler warning by initializing a variable.Jeffrey C. Ollie
If Xapian threw an exception on notmuch_query_count_messages the count variable could be used uninitialized. Initialize count to solve the problem. Signed-off-by: Jeffrey C. Ollie <jeff@ocjtech.us>
2009-11-27have _notmuch_thread_create mark which messages matched the queryBart Trojanowski
When _notmuch_thread_create() is given a query string, it can return more messages than just those matching the query. To distinguish those that matched the query expression, the MATCHING_SEARCH flag is set appropriately. Signed-off-by: Bart Trojanowski <bart@jukie.net>
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-26lib: New function to collect tags from a list of messages.Jan Janak
This patch adds a new function that can be used to collect a list of unique tags from a list of messages. 'notmuch search-tags' uses the function to get a list of tags from messages matching a search-term, but it has the potential to be used elsewhere so we put it in the lib. Signed-off-by: Jan Janak <jan@ryngle.com>
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-24lib/messages.c: Make message searches stream as well.Carl Worth
Xapian provides an interator-based interface to all search results. So it was natural to make notmuch_messages_t be iterator-based as well. Which we did originally. But we ran into a problem when we added two APIs, (_get_replies and _get_toplevel_messages), that want to return a messages iterator that's *not* based on a Xapian search result. My original compromise was to use notmuch_message_list_t as the basis for all returned messages iterators in the public interface. This had the problem of introducing extra latency at the beginning of a search for messages, (the call would block while iterating over all results from Xapian, converting to a message list). In this commit, we remove that initial conversion and instead provide two alternate implementations of notmuch_messages_t (one on top of a Xapian iterator and one on top of a message list). With this change, I tested a "notmuch search" returning *many* results as previously taking about 7 seconds before results started appearing, and now taking only 2 seconds.
2009-11-23lib/query: Drop the first and max_messages arguments from search_messages.Carl Worth
These only existed to support the chunky-searching hack, but that was recently dropped anyway.
2009-11-23lib/query: Fix notmuch_threads_t to stream results rather than blocking.Carl Worth
Previously, notmuch_query_search_threads would do all the work, so the caller would block until all results were processed. Now, we do the work as we go, as the caller iterates with notmuch_threads_next. This means that once results start coming back from "notmuch search" they just keep continually streaming. There's still some initial blocking before the first results appear because the notmuch_messages_t object has the same bug (for now).
2009-11-23notmuch search: Remove the chunked-searching hack.Carl Worth
This was a poor workaround around the fact that the existing notmuch_threads_t object is implemented poorly. It's got a fine iterartor-based interface, but the implementation does all of the work up-front in _create rather than doing the work incrementally while iterating. So to start fixing this, first get rid of all the hacks we had working around this. This drops the --first and --max-threads options from the search command, (but hopefully nobody was using them anyway---notmuch.el certainly wasn't).
2009-11-23Add rudimentary date-based search.Carl Worth
The rudimentary aspect here is that the date ranges are specified with UNIX timestamp values (number of seconds since 1970-01-01 UTC). One thing that can help here is using the date program to determins timestamps, such as: $(date +%s -d 2009-10-01)..$(date +%s) Long-term, we'll probably need to do our own query parsing to be able to support directly-specified dates and also relative expressions like "since:'2 months ago'".
2009-11-23Add 'notmuch count' command to show the count of matching messagesKeith Packard
Getting the count of matching threads or messages is a fairly expensive operation. Xapian provides a very efficient mechanism that returns an approximate value, so use that for this new command. This returns the number of matching messages, not threads, as that is cheap to compute. Signed-off-by: Keith Packard <keithp@keithp.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-22lib/database.cc: coding styleChris Wilson
Carl claims he must have been distracted when he wrote this... Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2009-11-22Makefile: Magic silent rules.Chris Wilson
Use the facilities of GNU make to create a magic function that will on the first invocation print a description of how to enable verbose compile lines and then print the quiet rule. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Carl Worth <cworth@cworth.org> Cc: Mikhail Gusarov <dottedmag@dottedmag.net> [ickle: Rebased, and duplicate command string eliminated.] [ickle: Fixed verbose bug pointed out by Mikhail]
2009-11-22add_message: Use sha-1 in place of overly long message ID.Carl Worth
Since Xapian has a limit on the maximum length of a term, we have to check for that before trying to add the message ID as a term. This fixes the bug reported by Mike Hommey here: <20091120132625.GA19246@glandium.org> I've also constructed 20 files with a range of message ID lengths centered around the Xapian term-length limit which I'll use to seed a new test suite soon.