aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/database.cc
Commit message (Collapse)AuthorAge
...
* Add missing comment for NOTMUCH_STATUS_READONLY_DATABASE.Gravatar Carl Worth2010-01-06
| | | | And adjust the string representation of the same to match.
* lib: Implement new notmuch_directory_t API.Gravatar Carl Worth2010-01-06
| | | | | | | 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.
* database: Add new, public notmuch_database_remove_messageGravatar Carl Worth2010-01-06
| | | | | | 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".
* database: Add new find_doc_ids_for_term interface.Gravatar Carl Worth2010-01-06
| | | | | | | | 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.
* database: Make find_unique_doc_id enforce uniqueness (for a debug build)Gravatar Carl Worth2010-01-06
| | | | | Catching any violation of this unique-ness constraint is very much in line with similar, existing INTERNAL_ERROR cases.
* database: Abstract _filename_to_direntry from _add_messageGravatar Carl Worth2010-01-06
| | | | | | 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 .
* database: Allowing storing multiple filenames for a single message ID.Gravatar Carl Worth2010-01-06
| | | | | | 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.
* database: Store mail filename as a new 'direntry' term, not as 'data'.Gravatar Carl Worth2010-01-06
| | | | | | | | | | 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.
* database: Split _find_parent_id into _split_path and _find_directory_idGravatar Carl Worth2010-01-06
| | | | | | 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.
* database: Store directory path in 'data' of directory documents.Gravatar Carl Worth2010-01-06
| | | | | | | | 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).
* database: Export _notmuch_database_find_parent_id for internal use.Gravatar Carl Worth2010-01-06
| | | | | | 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.
* database: Store the parent ID for each directory document.Gravatar Carl Worth2010-01-06
| | | | | | | 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).
* database: Rename internal directory value from XTIMESTAMP to XDIRECTORY.Gravatar Carl Worth2010-01-06
| | | | | | | | 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).
* database: Store directory paths as relative, not absolute.Gravatar Carl Worth2010-01-06
| | | | | | | 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.
* lib: Document that the filename is stored in the 'data' of a mail documentGravatar Carl Worth2010-01-06
| | | | | | Our database schema documentation previously didn't give any indication of where this most essential piece of information is stored.
* lib: Rename set/get_timestamp to set/get_directory_mtime.Gravatar Carl Worth2010-01-06
| | | | | | I've been suitably scolded by Keith for doing a premature generalization that ended up just making the documentation more convoluted. Fix that.
* lib: Abstract the extraction of a relative path from set_filenameGravatar Carl Worth2010-01-06
| | | | | | 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.
* Nuke the remainings of _notmuch_message_add_thread_id.Gravatar Fernando Carrijo2009-12-09
| | | | | | | | | | 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>
* notmuch: New function to retrieve all tags from the database.Gravatar Jan Janak2009-11-26
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add rudimentary date-based search.Gravatar Carl Worth2009-11-23
| | | | | | | | | | | | | 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'".
* lib/database.cc: coding styleGravatar Chris Wilson2009-11-22
| | | | | | Carl claims he must have been distracted when he wrote this... Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* add_message: Use sha-1 in place of overly long message ID.Gravatar Carl Worth2009-11-22
| | | | | | | | | | | | | 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.
* get_timestamp: Ensure that return value is 0 in case of exception.Gravatar Carl Worth2009-11-22
| | | | Just to be on the safe side of things.
* Catch and optionally print about exception at database->flush.Gravatar Carl Worth2009-11-22
| | | | | | | 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.
* Print information about where Xapian exception occurred.Gravatar Carl Worth2009-11-22
| | | | | Previously, our Xapian exception reports where identical so they were hard to track down.
* Rename NOTMUCH_DATABASE_MODE_WRITABLE to NOTMUCH_DATABASE_MODE_READ_WRITEGravatar Carl Worth2009-11-21
| | | | And correspondingly, READONLY to READ_ONLY.
* Permit opening the notmuch database in read-only mode.Gravatar Chris Wilson2009-11-21
| | | | | | | | | 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>
* add_message: Re-fix handling of non-mail files.Gravatar Carl Worth2009-11-20
| | | | | | | | | | | 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.
* notmuch_database_add_message: Add missing error-value propagation.Gravatar Carl Worth2009-11-20
| | | | | Thanks to Mike Hommey for doing the analysis that led to noticing that this was missing.
* add_message: Properly handle missing Message-ID once again.Gravatar Carl Worth2009-11-20
| | | | | | | | 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).
* TypsosGravatar Ingmar Vanhassel2009-11-18
|
* linke_message: Avoid segfault when In-Reply-to header is empty.Gravatar Carl Worth2009-11-18
| | | | | | | | | | | | | 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?
* database: Make _parse_message_id static once again.Gravatar Carl Worth2009-11-17
| | | | | | | 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.
* database: Add "replyto" to the database schema documentation.Gravatar Carl Worth2009-11-17
| | | | | | 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.
* database: Rename "ref" prefix name to "reference"Gravatar Carl Worth2009-11-17
| | | | | | | Which is more consistent with the XREFERENCE prefix used in the terms in the database. Also remove some stale documentation describing the removal of resolved references from the database (we no longer do this).
* add_message: Don't add any self-references to the database.Gravatar Carl Worth2009-11-17
| | | | | | In our scheme it's illegal for any message to refer to itself, (nor would it be useful for anything anyway). Cut these self-references off at the source, before they trip up any internal errors.
* Remove the talloc_owner argument from create_for_message_id.Gravatar Carl Worth2009-11-17
| | | | | | | 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.
* Fix broken commit.Gravatar Carl Worth2009-11-17
| | | | Oops. I should have actually compiled before pushing.
* add_message: Avoid a memory leak when user holds on to message return.Gravatar Carl Worth2009-11-17
| | | | | | | | | | When this function was originally written, the 'message' object was always destroyed locally, so I thought it would be good to use a NULL talloc context to make it more obvious if there was any leak. Since then, however, this function has been changed to optionally return the added message, and in that case we *don't* free the message locally, so let's let the database be the talloc context.
* database: Fix a typo in a commit.Gravatar Carl Worth2009-11-15
| | | | | Nothing significant here, but we might as well not keep things misspelled when we notice.
* Export _parse_message_id to the library implementation.Gravatar Carl Worth2009-11-15
| | | | | | Not exported through the public interface, but the thread code is going to want to be able to parse In-Reply-To headers so needs access to this code.
* Don't create "contact" terms in the database.Gravatar Carl Worth2009-11-12
| | | | | | | | | | | We never did export any interface to get at these, and when I went to use these, I found them inadequate, (because I wanted to distinguish address found in from: from those found in To:). Meanwhile, it was easy enough to extract addresses with a search like: notmuch show tag:sent | grep ^To: so the storage of contact terms was just wasting space. Stop that.
* notmuch: Add a configuration system.Gravatar Carl Worth2009-11-11
| | | | | | | | | | | | | | This will allow for things like the database path to be specified without any cheesy NOTMUCH_BASE environment variable. It also will allow "notmuch reply" to recognize the user's email address when constructing a reply in order to do the right thing, (that is, to use the user's address to which mail was sent as From:, and not to reply to the user's own addresses). With this change, the "notmuch setup" command is now strictly for changing the configuration of notmuch. It no longer creates the database, but instead instructs the user to call "notmuch new" to do that.
* libify: Move library sources down into lib directory.Gravatar Carl Worth2009-11-09
A "make" invocation still works from the top-level, but not from down inside the lib directory yet.