aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
Commit message (Collapse)AuthorAge
* lib: Treat messages in new/ as maildir messages with no flags setGravatar Austin Clements2012-06-10
| | | | | | | | | | | | Previously, notmuch new only synchronized maildir flags to tags for files with a maildir "info" part. Since messages in new/ don't have an info part, notmuch would ignore them for flag-to-tag synchronization. This patch makes notmuch consider messages in new/ to be legitimate maildir messages that simply have no maildir flags set. The most visible effect of this is that such messages now automatically get the unread tag.
* lib: Only synchronize maildir flags for messages in maildirsGravatar Austin Clements2012-06-10
| | | | | | | | | | | | | Previously, we synchronized flags to tags for any message that looked like it had maildir flags in its file name, regardless of whether it was in a maildir-like directory structure. This was asymmetric with tag-to-flag synchronization, which only applied to messages in directories named new/ and cur/ (introduced by 95dd5fe5). This change makes our interpretation stricter and addresses this asymmetry by only synchronizing flags to tags for messages in directories named new/ or cur/. It also prepares us to treat messages in new/ as maildir messages, even though they lack maildir flags.
* lib: Move _filename_is_in_maildirGravatar Austin Clements2012-06-10
| | | | | | This way notmuch_message_maildir_flags_to_tags can call it. It makes more sense for this to be just above all of the maildir synchronization code rather than mixed in the middle.
* lib: Don't needlessly create directory docs in _notmuch_message_remove_filenameGravatar Austin Clements2012-05-23
| | | | | | Previously, if passed a filename with a directory that did not exist in the database, _notmuch_message_remove_filename would needlessly create that directory document. Fix it so that doesn't happen.
* lib: Make notmuch_database_find_message_by_filename not crash on read-only ↵Gravatar Austin Clements2012-05-23
| | | | | | | | | | | databases Previously, _notmuch_database_filename_to_direntry would abort with an internal error when called on a read-only database. Now that creating the directory document is optional, notmuch_database_find_message_by_filename can disable directory document creation (as it should) and, as a result, not abort on read-only databases.
* lib: Make notmuch_database_get_directory return NULL if the directory is not ↵Gravatar Austin Clements2012-05-23
| | | | | | | | | | | | | | | found Using the new support from _notmuch_directory_create, this makes notmuch_database_get_directory a read-only operation that simply returns the directory object if it exists or NULL otherwise. This also means that notmuch_database_get_directory can work on read-only databases. This change breaks the directory mtime workaround in notmuch-new.c by fixing the exact issue it was working around. This permits mtime update races to prevent scans of changed directories, which non-deterministically breaks a few tests. The next patch fixes this.
* lib: Perform the same transformation to _notmuch_database_filename_to_direntryGravatar Austin Clements2012-05-23
| | | | | | Now _notmuch_database_filename_to_direntry takes a flags argument and can indicate if the necessary directory documents do not exist. Again, callers have been updated, but retain their original behavior.
* lib: Perform the same transformation to _notmuch_database_find_directory_idGravatar Austin Clements2012-05-23
| | | | | | | Now _notmuch_database_find_directory_id takes a flags argument, which it passes through to _notmuch_directory_create and can indicate if the directory does not exist. Again, callers have been updated, but retain their original behavior.
* lib: Make directory document creation optional for _notmuch_directory_createGravatar Austin Clements2012-05-23
| | | | | | | | | | | Previously this function would create directory documents if they didn't exist. As a result, it could only be used on writable databases. This adds an argument to make creation optional and to make this function work on read-only databases. We use a flag argument to avoid a bare boolean and to permit future expansion. Both callers have been updated, but currently retain the old behavior. We'll take advantage of the new argument in the following patches.
* lib/cli: Make notmuch_database_get_directory return a status codeGravatar Austin Clements2012-05-15
| | | | | | | | | | | | | | Previously, notmuch_database_get_directory had no way to indicate how it had failed. This changes its prototype to return a status code and set an out-argument to the retrieved directory, like similar functions in the library API. This does *not* change its currently broken behavior of creating directory objects when they don't exist, but it does document it and paves the way for fixing this. Also, it can now check for a read-only database and return NOTMUCH_STATUS_READ_ONLY_DATABASE instead of crashing. In the interest of atomicity, this also updates calls from the CLI so that notmuch still compiles.
* lib: Bump SO version from 2.0.0 to 3.0.0Gravatar Austin Clements2012-05-05
| | | | | | | We've changed the APIs of notmuch_database_open, notmuch_database_create, and notmuch_database_close. Amended by db: also bump string in bindings/python/notmuch/globals.py
* lib/cli: Make notmuch_database_create return a status codeGravatar Austin Clements2012-05-05
| | | | | | | | This is the notmuch_database_create equivalent of the previous change. In this case, there were places where errors were not being propagated correctly in notmuch_database_create or in calls to it. These have been fixed, using the new status value.
* lib/cli: Make notmuch_database_open return a status codeGravatar Austin Clements2012-05-05
| | | | | | | | | | | | It has been a long-standing issue that notmuch_database_open doesn't return any indication of why it failed. This patch changes its prototype to return a notmuch_status_t and set an out-argument to the database itself, like other functions that return both a status and an object. In the interest of atomicity, this also updates every use in the CLI so that notmuch still compiles. Since this patch does not update the bindings, the Python bindings test fails.
* Split notmuch_database_close into two functionsGravatar Justus Winter2012-04-28
| | | | | | | | | | | | | | | | | | Formerly notmuch_database_close closed the xapian database and destroyed the talloc structure associated with the notmuch database object. Split notmuch_database_close into notmuch_database_close and notmuch_database_destroy. This makes it possible for long running programs to close the xapian database and thus release the lock associated with it without destroying the data structures obtained from it. This also makes the api more consistent since every other data structure has a destructor function. The comments in notmuch.h are a courtesy of Austin Clements. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* lib: work around talloc_steal usage from C++ codeGravatar Jani Nikula2012-04-15
| | | | | | | | | | | | | | | | Implicit typecast from 'void *' to 'T *' is okay in C, but not in C++. In talloc_steal, an explicit cast is provided for type safety in some GCC versions. Otherwise, a cast is required. Provide a template function for this to maintain type safety, and redefine talloc_steal to use it. The template must be outside the extern "C" block (NOTMUCH_BEGIN_DECLS and NOTMUCH_END_DECLS), but keep it within the GCC visibility #pragma. No functional changes, apart from making the library build with compilers other than recent GCC. Signed-off-by: Jani Nikula <jani@nikula.org>
* lib: change default for notmuch_query_set_omit_excludedGravatar Mark Walters2012-04-07
|
* lib: fix an exclude bugGravatar Mark Walters2012-03-18
| | | | | | | | | | When the exclude tags contain a tag that does not occur anywhere in the Xapian database the exclusion fails. We modify the way the query is constructed to `work around' this. (In fact the new code is cleaner anyway.) It also seems to fix another exclusion failure bug reported by jrollins but we have not yet worked out why it helps in that case.
* lib: Add exclude query debug outputGravatar Austin Clements2012-03-18
|
* lib: Expose query debug output via an environment variableGravatar Austin Clements2012-03-18
| | | | | | | | | Allow query debugging to be enabled at run-time by setting the NOTMUCH_DEBUG_QUERY environment variable to a non-empty string. Previously, enabling query debugging required recompiling, but parsed queries are often useful for tracking down bugs in situations where recompiling is inconvenient.
* Merge tag '0.12_rc2'Gravatar David Bremner2012-03-18
|\ | | | | | | notmuch 0.12~rc2 release
| * Fix error reporting in notmuch_database_find_message_by_filenameGravatar Justus Winter2012-03-18
| | | | | | | | | | | | | | | | | | Formerly it was possible for *message_ret to be left uninitialized. The documentation however clearly states that "[o]n any failure or when the message is not found, this function initializes '*message' to NULL". Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* | Merge branch 'release'Gravatar David Bremner2012-03-03
|\|
| * Actually close the xapian database in notmuch_database_closeGravatar Justus Winter2012-03-03
| | | | | | | | | | | | | | | | | | | | | | Formerly the xapian database object was deleted and closed in its destructor once the object was garbage collected. Explicitly call close() so that the database and the associated lock is released immediately. The comment is a courtesy of Austin Clements. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* | lib: Add the exclude flag to notmuch_query_search_threadsGravatar Mark Walters2012-03-02
| | | | | | | | | | | | | | | | | | | | | | Add the NOTMUCH_MESSAGE_FLAG_EXCLUDED flag to notmuch_query_search_threads. Implemented by inspecting the tags directly in _notmuch_thread_create/_thread_add_message rather than as a Xapian query for speed reasons. Note notmuch_thread_get_matched_messages now returns the number of non-excluded matching messages. This API is not totally desirable but fixing it means breaking binary compatibility so we delay that.
* | lib: Make notmuch_query_search_messages set the exclude flagGravatar Mark Walters2012-03-02
| | | | | | | | | | | | | | | | | | | | Add a flag NOTMUCH_MESSAGE_FLAG_EXCLUDED which is set by notmuch_query_search_messages for excluded messages. Also add an option omit_excluded_messages to the search that we do not want the excludes at all. This exclude flag will be added to notmuch_query_search threads in the next patch.
* | lib: Rearrange the exclude code in query.ccGravatar Mark Walters2012-03-02
|/ | | | | Slightly refactor the exclude code to give the callers access to the exclude query itself. There should be no functional change.
* Convert non-UTF-8 parts to UTF-8 before indexing themGravatar Michal Sojka2012-02-29
| | | | | | | This fixes a bug that didn't allow to search for non-ASCII words such parts. The code here was copied from show_text_part_content(), because the show command already does the needed conversion when showing the message.
* Prevent segmentation fault in notmuch_database_closeGravatar Justus Winter2012-02-20
| | | | | | | | | | | | Previously opening a notmuch database in read write mode that has been locked resulted in the notmuch_database_open function executing notmuch_database_close as a cleanup function. notmuch_database_close failed to check whether the xapian database has in fact been created. Add a check whether the xapian database object has actually been created before trying to call its flush method. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* lib: Use talloc to simplify cleanup in notmuch_database_openGravatar Austin Clements2012-02-03
| | | | | | | Previously, we manually "free"d various pointers in notmuch_database_open. Use a local talloc context instead to simplify cleanup and eliminate various NULL pointer initializations and conditionals.
* lib: Release resources if notmuch_database_open failsGravatar Austin Clements2012-02-03
| | | | | Previously, if a Xapian exception occurred in notmuch_database_open, we failed to clean up the allocated notmuch_database_t object.
* lib: Don't delete uninitialized pointersGravatar Austin Clements2012-02-03
| | | | | | | | | In the error-handling paths of notmuch_database_open, we call notmuch_database_close, which "delete"s several objects referenced by the notmuch_database_t object. However, some of these pointers may be uninitialized, resulting in undefined behavior. Hence, allocate the notmuch_database_t with talloc_zero to make sure these pointers are NULL so that "delete"ing them is harmless.
* lib: Add support for automatically excluding tags from queriesGravatar Austin Clements2012-01-16
| | | | | | This is useful for tags like "deleted" and "spam" that people generally want to exclude from query results. These exclusions will be overridden if a tag is explicitly mentioned in a query.
* lib: fix messages.c build warnGravatar Jani Nikula2012-01-10
| | | | | | | lib/messages.c: In function ‘notmuch_messages_move_to_next’: lib/messages.c:131:2: warning: ISO C forbids ‘return’ with expression, in function returning void [-pedantic] Signed-off-by: Jani Nikula <jani@nikula.org>
* lib: call g_mime_init() from notmuch_database_open()Gravatar Kazuo Teramoto2011-12-31
| | | | | | | | | | | | | | As reported in id:"CAEbOPGyuHnz4BPtDutnTPUHcP3eYcRCRkXhYoJR43RUMw671+g@mail.gmail.com" sometimes gmime tries to access a NULL pointer, e.g. g_mime_iconv_open() tries to access iconv_cache that is NULL if g_mime_init() is not called. This causes notmuch to segfault when calling gmime functions. Calling g_mime_init() initializes iconv_cache and others variables needed by gmime, making sure they are initialized when notmuch calls gmime functions. Test marked fix by db.
* Ignore encrypted parts when indexing.Gravatar Jameson Graef Rollins2011-12-29
| | | | | | | | It appears to be an oversight that encrypted parts were indexed previously. The terms generated from encrypted parts are meaningless and do nothing but add bloat to the database. It is not worth indexing the encrypted content, just as it's not worth indexing the signatures in signed parts.
* Fix comments about what is stored in the databaseGravatar Thomas Jost2011-12-23
| | | | | | Commit 567bcbc2 introduced two new values for each message (content of the "From" and "Subject" headers), but the comments about the database schema had not been updated accordingly.
* notmuch: Quiet buildbot warnings.Gravatar David Edmondson2011-12-21
| | | | | Cast away the result of various *write functions. Provide a default value for some variables to avoid "use before set" warnings.
* Merge branch 'release'Gravatar David Bremner2011-12-06
|\ | | | | | | | | | | | | Conflicts: NEWS Conflicts resolved by inserting the 0.10.2 stanza before 0.11
| * lib: call g_type_init from notmuch_database_openGravatar David Bremner2011-12-04
| | | | | | | | | | We want to make sure g_type_init is called before any GObject functionality is used.
* | tags_to_maildir_flags: Cleanup double assignementGravatar Louis Rilling2011-11-21
| | | | | | | | | | | | The for loop right after already does the job. Signed-off-by: Louis Rilling <l.rilling@av7.net>
* | lib: Kill last usage of C++ type boolGravatar Louis Rilling2011-11-21
| | | | | | | | Signed-off-by: Louis Rilling <l.rilling@av7.net>
* | Don't link libnotmuch if libutil isn't linked in properly.Gravatar Tom Prince2011-11-19
|/ | | | | | | For some reason, on my machine, the link is picking up /usr/lib/libutil.so instead of util/libutil.a. This causes there to be undefined symbols in libnotmuch, making it unuseable. This patch causes the link to fail instead.
* lib: add function to get the number of threads matching a searchGravatar Jani Nikula2011-11-15
| | | | | | | | | Add function notmuch_query_count_threads() to get the number of threads matching a search. This is done by performing a search and figuring out the number of unique thread IDs in the matching messages, a significantly heavier operation than notmuch_query_count_messages(). Signed-off-by: Jani Nikula <jani@nikula.org>
* Store "from" and "subject" headers in the database.Gravatar Austin Clements2011-11-14
| | | | | | | | | | | | | | This is a rebase and cleanup of Istvan Marko's patch from id:m3pqnj2j7a.fsf@zsu.kismala.com Search retrieves these headers for every message in the search results. Previously, this required opening and parsing every message file. Storing them directly in the database significantly reduces IO and computation, speeding up search by between 50% and 10X. Taking full advantage of this requires a database rebuild, but it will fall back to the old behavior for messages that do not have headers stored in the database.
* Link libutil using filenmae, rather than using -l.Gravatar Tom Prince2011-11-13
| | | | | glibc includes a libutil, so if the wrong -L options get passed, we will pick up glibc's version, rather than our own.
* lib/database.cc: use flush Xapian method instead of commitGravatar David Bremner2011-11-02
| | | | | | | Apparently the method was renamed in Xapian 1.1.0 but the old method name will stay around for a while. It seems better to stick with the old name to make notmuch compile with older versions of Xapian, at least for now.
* xutil.c: remove duplicate copies, create new library libutil.a to contain xutil.Gravatar David Bremner2011-10-30
| | | | | | | We keep the lib/xutil.c version. As a consequence, also factor out _internal_error and associated macros. It might be overkill to make a new file error_util.c for this, but _internal_error does not really belong in database.cc.
* Prefix lib/notmuch.h and lib/gen-version-script.sh with $(srcdir)Gravatar Amadeusz Żołnowski2011-10-24
| | | | | lib/notmuch.h and lib/gen-version-script.sh couldn't have been found when building out of sources directory.
* lib: bump SONAMEGravatar David Bremner2011-10-04
| | | | | | | | | | | Based on discussions with amdragon, tschwinge, and others on IRC, I concluded that 1) symbol versioning was probably overkill for libnotmuch 2) It was also probably GNU ld specific 3) Most importantly, nobody could tell me on short notice how exactly it works. So since the change to the notmuch_database_find_message breaks the previous ABI, we need to bump the SONAME.
* lib: make find_message{,by_filename) report errorsGravatar Ali Polatel2011-10-04
| | | | | | | | | | | | | | | | Previously, the functions notmuch_database_find_message() and notmuch_database_find_message_by_filename() functions did not properly report error condition to the library user. For more information, read the thread on the notmuch mailing list starting with my mail "id:871uv2unfd.fsf@gmail.com" Make these functions accept a pointer to 'notmuch_message_t' as argument and return notmuch_status_t which may be used to check for any error condition. restore: Modify for the new notmuch_database_find_message() new: Modify for the new notmuch_database_find_message_by_filename()