summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2017-03-07lib: Fix RegexpPostingSourceOlly Betts
Remove incorrect skipping to first match from init(), and add explicit skip_to() and check() methods to work around xapian-core bug (the check() method will also improve speed when filtering by one of these).
2017-03-04lib: query make exclude handling non-destructiveDavid Bremner
We filter added exclude at add time, rather than modifying the query by count search. As noted in the comments, there are several ignored conditions here.
2017-03-04lib: centralize query parsing, store results.David Bremner
The main goal is to prepare the way for non-destructive (or at least less destructive) exclude tag handling. It does this by having a pre-parsed query available for further processing. This also allows us to provide slightly more precise error messages.
2017-03-04lib: use delete[] to free buffer allocated using new[]Jani Nikula
Fix warning caught by clang: lib/regexp-fields.cc:41:2: warning: 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'? [-Wmismatched-new-delete] delete buffer; ^ [] lib/regexp-fields.cc:37:17: note: allocated with 'new[]' here char *buffer = new char[len]; ^
2017-03-03lib: add mid: as a synonym for id:David Bremner
mid: is the url scheme suggested by URL 2392. We also plan to introduce more flexible searches for mid: than are possible with id: (in order not to break assumptions about the special behaviour of id:, e.g. identifying at most one message).
2017-03-03lib: regexp matching in 'subject' and 'from'David Bremner
the idea is that you can run % notmuch search subject:/<your-favourite-regexp>/ % notmuch search from:/<your-favourite-regexp>/ or % notmuch search subject:"your usual phrase search" % notmuch search from:"usual phrase search" This feature is only available with recent Xapian, specifically support for field processors is needed. It should work with bindings, since it extends the query parser. This is easy to extend for other value slots, but currently the only value slots are date, message_id, from, subject, and last_mod. Date is already searchable; message_id is left for a followup commit. This was originally written by Austin Clements, and ported to Xapian field processors (from Austin's custom query parser) by yours truly.
2017-03-03lib: create field processors from prefix tableDavid Bremner
This is a bit more code than hardcoding the two existing field processors, but it should make it easy to add more.
2017-02-25lib/message.cc: use view number to invalidate cached metadataDavid Bremner
Currently the view number is incremented by notmuch_database_reopen
2017-02-25lib: handle DatabaseModifiedError in _n_message_ensure_metadataDavid Bremner
The retries are hardcoded to a small number, and error handling aborts than propagating errors from notmuch_database_reopen. These are both somewhat justified by the assumption that most things that can go wrong in Xapian::Database::reopen are rare and fatal. Here's the brief discussion with Xapian upstream: 24-02-2017 08:12:57 < bremner> any intuition about how likely Xapian::Database::reopen is to fail? I'm catching a DatabaseModifiedError somewhere where handling any further errors is tricky, and wondering about treating a failed reopen as as "the impossible happened, stopping" 24-02-2017 16:22:34 < olly> bremner: there should not be much scope for failure - stuff like out of memory or disk errors, which are probably a good enough excuse to stop
2017-02-25lib: add _notmuch_database_reopenDavid Bremner
The main expected use is to recover from a Xapian::DatabaseChanged exception.
2017-02-23Merge branch 'release'David Bremner
Merge in g_hash_table read-after-free fix
2017-02-23lib: make _notmuch_message_ensure_property_map staticDavid Bremner
It's not called outside message.cc
2017-02-23lib: make _notmuch_message_ensure_metadata staticDavid Bremner
It's not called anywhere outside message.cc.
2017-02-22lib: fix g_hash_table related read-after-free bugDavid Bremner
The two g_hash_table functions (insert, add) have different behaviour with respect to existing keys. g_hash_table_insert frees the new key, while g_hash_table_add (which is really g_hash_table_replace in disguise) frees the existing key. With this change 'ref' is live until the end of the function (assuming single-threaded access to 'hash'). We can't guarantee it will continue to be live in the future (i.e. there may be a future key duplication) so we copy it with the allocation context passed to parse_references (in practice this is the notmuch_message_t object whose parents we are finding). Thanks to Tomi for the simpler approach to the problem based on reading the fine glib manual.
2017-02-18lib: Let Xapian manage the memory for FieldProcessorsDavid Bremner
It turns out this is exactly what release() is for; Xapian will deallocate the objects when it's done with them.
2017-02-18lib: merge internal prefix tablesDavid Bremner
Replace multiple tables with some flags in a single table. This makes the code in notmuch_database_open_verbose a bit shorter, and it should also make it easier to add other options to fields, e.g. regexp searching.
2017-01-27lib: optimize counting documentsDavid Bremner
From #xapian olly> bremner: btw, i noticed notmuch count see ms to request all the documents and then ignores them bremner> hmm. There's something funny about the way that notmuch uses matches in general iirc olly> it should be able to do: mset = enquire.get_mset (0, 0, notmuch->xapian_db->get_doccount ()); ... olly> get_matches_estimated() will be exact because check_at_least is the size of the database
2017-01-15docs: fix notmuch_message_properties_value documentationSteven Allen
It returns the value, not the key.
2017-01-08lib: use glib for sha1 digests instead of embedding libsha1Jani Nikula
We already depend on glib both directly and indirectly (via gmime). We might as well make use of its facilities. Drop the embedded libsha1 and use glib for sha1 digests.
2017-01-07lib: fix the todo comment placement on NOTMUCH_STATUS_XAPIAN_EXCEPTIONJani Nikula
The todo comment got separated from the status it's related to at commit 3f32fd8a1c06 ("Add missing comment for NOTMUCH_STATUS_READONLY_DATABASE."). Later, commit b65ca8e0ba5e ("lib: modify notmuch.h for automatic document generation") moved it, but to the wrong place. Fix the location.
2016-11-15lib: optionally silence Xapian deprecation warningsDavid Bremner
This is not ideal, but the new API is not available in Xapian 1.2.x, and it seems to soon to depend on Xapian >= 1.4
2016-10-25lib: replace deprecated xapian call 'flush()' with 'commit()'David Bremner
This will make notmuch incompatible with Xapian before 1.1.0, which is more than 6 years old this point.
2016-10-06lib: document API added in 0.23David Bremner
The API was already documented, but for future readers note when the functions were added,
2016-10-06require xapian >= 1.2.6David Bremner
It seems that no-one tried to compile without Xapian compact support since March of 2015, since that's when I introduced a syntax error in that branch of the ifdef. Given the choice of maintaining this underused branch of code, or bumping the Xapian dependency to a version from 2011, it seems reasonable to do the latter.
2016-10-01lib: bump minor version to mark added symbolsDavid Bremner
This should not change the SONAME, and therefore won't change the dynamic linking behaviour, but it may help some users debug missing symbols in case their libnotmuch is too old.
2016-09-28lib/database.cc: fix misleading indentationTomi Ollila
Found by gcc 6.1.1 -Wmisleading-indentation option (set by -Wall).
2016-09-24lib: add talloc reference from string map iterator to mapDavid Bremner
This is needed so that when the map is modified during traversal, and thus unlinked by the database code, the map is not disposed of until the iterator is done with it.
2016-09-21add property: query prefix to search for specific propertiesDaniel Kahn Gillmor
We want to be able to query the properties directly, like: notmuch count property:foo=bar which should return a count of messages where the property with key "foo" has value equal to "bar".
2016-09-21lib: iterator API for message propertiesDavid Bremner
This is a thin wrapper around the string map iterator API just introduced.
2016-09-21lib: extend private string map API with iteratorsDavid Bremner
Support for prefix based iterators is perhaps overengineering, but I wanted to mimic the existing database_config API.
2016-09-21lib: basic message-property APIDavid Bremner
Initially, support get, set and removal of single key/value pair, as well as removing all properties.
2016-09-21lib: private string map (associative array) APIDavid Bremner
The choice of array implementation is deliberate, for future iterator support
2016-09-21lib: read "property" terms from messages.David Bremner
This is a first step towards providing an API to attach arbitrary (key,value) pairs to messages and retrieve all of the values for a given key.
2016-08-23lib: update cached mtime in notmuch_directory_set_mtimeDavid Bremner
Without this change, the following code fails notmuch_directory_set_mtime(dir, 12345); assert(notmuch_directory_get_mtime(dir) == 12345);
2016-08-18lib: reword comment about XFOLDER: prefixDavid Bremner
I believe the current one is misleading, because in my experiments Xapian did not add : when prefix and term were both upper case. Indeed, it's hard to see how it could, because prefixes are added at a layer above Xapian in our code. See _notmuch_message_add_term for an example. Also try to explain why this is a good idea. As far as I can ascertain, this is more of an issue for a system trying to work with an unknown set of prefixes. Since notmuch has a fixed set of prefixes, and we can hopefully be trusted not to add XGOLD and XGOLDEN as prefixes, it is harder for problems to arise.
2016-08-09lib: provide _notmuch_database_log_appendDavid Bremner
_notmuch_database_log clears the log buffer each time. Rather than introducing more complicated semantics about for this function, provide a second function that does not clear the buffer. This is mainly a convenience function for callers constructing complex or multi-line log messages. The changes to query.cc are to make sure that the common code path of the new function is tested.
2016-06-29lib: add built_with handling for XAPIAN_DB_RETRY_LOCKDavid Bremner
This support will be present only if the appropriate version of xapian is available _and_ the user did not disable the feature when building. So there really needs to be some way for the user to check.
2016-06-29Use the Xapian::DB_RETRY_LOCK flag when availableIstvan Marko
Xapian 1.3 has introduced the DB_RETRY_LOCK flag (Xapian bug 275). Detect it in configure and optionally use it. With this flag commands that need the write lock will wait for their turn instead of aborting when it's not immediately available. Amended by db: allow disabling in configure
2016-06-28doc: forbid further operations on a closed databaseDavid Bremner
We could add many null pointer checks, but currently I don't see a use case that justifies it.
2016-06-11lib: fix definition of LIBNOTMUCH_CHECK_VERSIONDavid Bremner
Fix bug reported in id:20160606124522.g2y2eazhhrwjsa4h@flatcap.org Although the C99 standard 6.10 is a little non-obvious on this point, the docs for e.g. gcc are unambiguous. And indeed in practice with the extra space, this code fails #include <stdio.h> #define foo (x) (x+1) int main(int argc, char **argv){ printf("%d\n",foo(1)); }
2016-06-10lib: fix memory leak of field processor objectsDavid Bremner
The field processor objects need to be deallocated explicitly just like the range processors (or a talloc destructor defined).
2016-06-07lib: document config metadataDavid Bremner
This probably should have been part of 3458e3c89c, but I missed it.
2016-06-05Use https instead of http where possibleDaniel Kahn Gillmor
Many of the external links found in the notmuch source can be resolved using https instead of http. This changeset addresses as many as i could find, without touching the e-mail corpus or expected outputs found in tests.
2016-06-05lib: whitespace cleanupTomi Ollila
Cleaned the following whitespace in lib/* files: lib/index.cc: 1 line: trailing whitespace lib/database.cc 5 lines: 8 spaces at the beginning of line lib/notmuch-private.h: 4 lines: 8 spaces at the beginning of line lib/message.cc: 1 line: trailing whitespace lib/sha1.c: 1 line: empty lines at the end of file lib/query.cc: 2 lines: 8 spaces at the beginning of line lib/gen-version-script.sh: 1 line: trailing whitespace
2016-05-25lib: add support for named queriesDavid Bremner
This relies on the optional presense of xapian field processors, and the library config API.
2016-05-25lib: make a global constant for query parser flagsDavid Bremner
It's already kindof gross that this is hardcoded in two different places. We will also need these later in field processors calling back into the query parser.
2016-05-25lib: config list iteratorsDavid Bremner
Since xapian provides the ability to restrict the iterator to a given prefix, we expose this ability to the user. Otherwise we mimic the other iterator interfances in notmuch (e.g. tags.c).
2016-05-24lib: provide config APIDavid Bremner
This is a thin wrapper around the Xapian metadata API. The job of this layer is to keep the config key value pairs from colliding with other metadata by transparently prefixing the keys, along with the usual glue to provide a C interface. The split of _get_config into two functions is to allow returning of the return value with different memory ownership semantics.
2016-05-13lib/cli: add library API / CLI for compile time optionsDavid Bremner
This is intentionally low tech; if we have more than two options it may make sense to build up what infrastructure is provided.
2016-05-08lib: optionally support single argument date: queriesDavid Bremner
This relies on the FieldProcessor API, which is only present in xapian >= 1.3.