aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
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.
2009-11-22get_timestamp: Ensure that return value is 0 in case of exception.Carl Worth
Just to be on the safe side of things.
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-22Print information about where Xapian exception occurred.Carl Worth
Previously, our Xapian exception reports where identical so they were hard to track down.
2009-11-21Fix freak case problem that broke the compile.Carl Worth
I think I must have bumped some emacs keybinding that changed the case of a word here.
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-21When a search query triggers a Xapian exception, log what the query was.Eric Anholt
In my script containing a series of queries to be run on new mail for setting up tags, it's nice to see which query I typed wrong. Signed-off-by: Eric Anholt <eric@anholt.net>
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-20notmuch_database_add_message: Add missing error-value propagation.Carl Worth
Thanks to Mike Hommey for doing the analysis that led to noticing that this was missing.
2009-11-20add_message: Properly handle missing Message-ID once again.Carl Worth
There's been a fair amount of fallout from when we changed message_file_get_header from returning NULL to returning "" for missing headers. This is yet more fallout from that, (where we were accepting an empty message-ID rather than generating one like we want to).
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-19Allow lone "not" search operatorsAdrian Perez
As suggested by Keith in FLAG_PURE_NOT allows for expressions like: notmuch search NOT tag:inbox Note that this way a search like: notmuch search foobar NOT tag:inbox should not be written instead: notmuch search foobar AND NOT tag:inbox In my opinion, the latter feels more natural and is somewhat more explicit. It gives a better clue of what the search is about instead of assuming that an implicit AND operator is there.
2009-11-18TypsosIngmar Vanhassel
2009-11-18linke_message: Avoid segfault when In-Reply-to header is empty.Carl Worth
This was recently introduced in commit: 64c03ae97f2f5294c60ef25d7f41849864e6ebd3 which was adding extra checks to avoid adding a self-referencing message. How many times am I going to fix a dumb regression like this and say "we really need a test suite" before I actually sit down and write the test suite?
2009-11-17notmuch search: Change default search order to be newest messages first.Carl Worth
This is what most people want for a _search_ command. It's often different for actually reading mail in an inbox, (where it makes more sense to have results displayed in chronological order), but in such a case, ther user is likely using an interface that can simply pass the --sort=oldest-first option to "notmuch search". Here we're also change the sort enum from NOTMUCH_SORT_DATE and NOTMUCH_SORT_DATE_REVERSE to NOTMUCH_SORT_OLDEST_FIRST and NOTMUCH_SORT_NEWEST_FIRST. Similarly we replace the --reverse option to "notmuch search" with two options: --sort=oldest-first and --sort=newest-first. Finally, these changes are all tracked in the emacs interface, (which has no change in its behavior).
2009-11-17database: Make _parse_message_id static once again.Carl Worth
We had exposed this to the internal implementation for a short time, (only while we had the silly code fetching In-Reply-To values from message files instead of from the database). Make this private again as it should be.
2009-11-17database: Add "replyto" to the database schema documentation.Carl Worth
Maybe ths lack of this documentation is why I forgot we were actually storing this and wrote the ugly code to fetch In-Reply-To from message files rather than from the database.