summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2016-06-30lib: 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-30doc: 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-04-15complete ghost-on-removal-when-shared-thread-existsDaniel Kahn Gillmor
To fully complete the ghost-on-removal-when-shared-thread-exists proposal, we need to clear all ghost messages when the last active message is removed from a thread. Amended by db: Remove the last test of T530, as it no longer makes sense if we are garbage collecting ghost messages.
2016-04-15On deletion, replace with ghost when other active messages in threadDaniel Kahn Gillmor
There is no need to add a ghost message upon deletion if there are no other active messages in the thread. Also, if the message being deleted was a ghost already, we can just go ahead and delete it.
2016-04-15Introduce _notmuch_message_has_term()Daniel Kahn Gillmor
It can be useful to easily tell if a given message has a given term associated with it.
2016-04-15Add internal functions to search for alternate doc typesDaniel Kahn Gillmor
Publicly we are only exposing the non-ghost documents (of "type" "mail"). But internally we might want to inspect the ghost messages as well. This changeset adds two new private interfaces to queries to recover information about alternate document types.
2016-04-15fix thread breakage via ghost-on-removalDaniel Kahn Gillmor
implement ghost-on-removal, the solution to T590-thread-breakage.sh that just adds a ghost message after removing each message. It leaks information about whether we've ever seen a given message id, but it's a fairly simple implementation. Note that _resolve_message_id_to_thread_id already introduces new message_ids to the database, so i think just searching for a given message ID may introduce the same metadata leakage.
2016-04-12lib: clean up _notmuch_database_split_pathJani Nikula
Make the logic it a bit easier to read. No functional changes.
2016-04-12lib: fix handling of one character long directory names at top levelJani Nikula
The code to skip multiple slashes in _notmuch_database_split_path() skips back one character too much. This is compensated by a +1 in the length parameter to the strndup() call. Mostly this works fine, but if the path is to a file under a top level directory with one character long name, the directory part is mistaken to be part of the file name (slash == path in code). The returned directory name will be the empty string and the basename will be the full path, breaking the indexing logic in notmuch new. Fix the multiple slash skipping to keep the slash variable pointing at the last slash, and adjust strndup() accordingly. The bug was introduced in commit e890b0cf4011fd9fd77ebd87343379e4a778888b Author: Carl Worth <cworth@cworth.org> Date: Sat Dec 19 13:20:26 2009 -0800 database: Store the parent ID for each directory document. just a little over two months after the initial commit in the Notmuch code history, making this the longest living bug in Notmuch to date.
2016-03-14lib: NOTMUCH_DEPRECATED macro also for older compilersTomi Ollila
Some compilers (older than gcc 4.5 and clang 2.9) do support __attribute__ ((deprecated)) but not __attribute__ ((deprecated("message"))). Check if clang version is at least 3.0, or gcc version is at least 4.5 to define NOTMUCH_DEPRECATED as the latter variant above. Otherwise define NOTMUCH_DEPRECATED as the former variant above. For a bit simpler implementation clang 2.9 is not included to use the newer variant. It is just one release, and the older one works fine. Clang 3.0 was released around 2011-11 and gcc 5.1 2015-04-22 (therefore newer macro for gcc 4.5+)
2016-01-16clean up stray apostrophe in commentDaniel Kahn Gillmor
This is a nit-picky orthographical fix for an nit-picky ontological comment.
2016-01-16correct comment referring to notmuch_database_remove_messageDaniel Kahn Gillmor
notmuch_database_remove_message has no leading underscore in its name.
2015-11-23forbid atomic transactions on writable, upgradable databasesSteven Allen
We can't (but currently do) allow upgrades within transactions because upgrades need their own transactions. We don't want to re-use the current transaction because bailing out of an upgrade would mean loosing all previous changes (because our "atomic" transactions don't commit before hand). This gives us two options: 1. Fail at the beginning of upgrade (tell the user to end the transaction, upgrade, and start over). 2. Don't allow the user to start the transaction. I went with the latter because: 1. There is no reason to call `begin_atomic` unless you intend to to write to the database and anyone intending to write to the database should upgrade it first. 2. This means that nothing inside an atomic transaction can ever fail with NOTMUCH_STATUS_UPGRADE_REQUIRED.
2015-11-19lib: content disposition values are not case-sensitiveJani Nikula
Per RFC 2183, the values for Content-Disposition values are not case-sensitive. While at it, use the gmime function for getting at the disposition string instead of referencing the field directly. This fixes "attachment" tagging and filename term generation for attachments while indexing.
2015-10-27Documentation: fix type name spellingSteven Allen
2015-10-10lib: add interface to delete directory documentsJani Nikula
As mentioned in acd66cdec075312944e527febd46382e54d99367 we don't have an interface to delete directory documents, and they're left behind. Add the interface.
2015-10-05lib: update doxygen comments to add @since for the new _st APIDavid Bremner
We should probably to this for all new functions introduced from now on.
2015-10-05lib: migrate thread.cc to new query_search APIDavid Bremner
here we rely on thread_id_query being attached to the local talloc context, so no new cleanup code is needed.
2015-10-05lib: migrate notmuch_database_upgrade to new query_search APIDavid Bremner
Here we depend on the error path cleaning up query
2015-10-05lib: add versions of n_q_count_{message,threads} with status returnDavid Bremner
Although I think it's a pretty bad idea to continue using the old API, this allows both a more gentle transition for clients of the library, and allows us to break one monolithic change into a series
2015-10-05lib: move query variable to function scopeDavid Bremner
This is a prelude to deallocating it (if necessary) on the error path.
2015-09-25lib: add support for date:<expr>..! to mean date:<expr>..<expr>Jani Nikula
It doesn't seem likely we can support simple date:<expr> expanding to date:<expr>..<expr> any time soon. (This can be done with a future version of Xapian, or with a custom query query parser.) In the mean time, provide shorthand date:<expr>..! to mean the same. This is useful, as the expansion takes place before interpetation, and we can use, for example, date:yesterday..! to match from beginning of yesterday to end of yesterday. Idea from Mark Walters <markwalters1009@gmail.com>.
2015-09-23lib: constify arguments to notmuch_query_get_*David Bremner
These functions are all just accessors, and it's pretty clear they don't modify the query struct. This also fixes one warning I created when I introduced status.c.
2015-09-07util: move strcase_equal and strcase_hash to utilJani Nikula
For future use in both cli and lib.
2015-09-04lib: constify argument to notmuch_database_status_stringDavid Bremner
We don't modify the database struct, so no harm in committing to that.
2015-09-04lib: note remaining uses of deprecated message search APIDavid Bremner
The two remaining cases in the lib seem to require more than a simple replacement of the old call, with the new call plus a check of the return value.
2015-09-04lib: remove use of notmuch_query_search_messages from query.ccDavid Bremner
There is not too much point in worrying about the bad error reporting here, because the count api is due for the same deprecation.
2015-08-14lib: Add "lastmod:" queries for filtering by last modificationAustin Clements
The implementation is essentially the same as the date range search prior to Jani's fancy date parser.
2015-08-13lib: API to retrieve database revision and UUIDAustin Clements
This exposes the committed database revision to library users along with a UUID that can be used to detect when revision numbers are no longer comparable (e.g., because the database has been replaced).
2015-08-13lib: Add per-message last modification trackingAustin Clements
This adds a new document value that stores the revision of the last modification to message metadata, where the revision number increases monotonically with each database commit. An alternative would be to store the wall-clock time of the last modification of each message. In principle this is simpler and has the advantage that any process can determine the current timestamp without support from libnotmuch. However, even assuming a computer's clock never goes backward and ignoring clock skew in networked environments, this has a fatal flaw. Xapian uses (optimistic) snapshot isolation, which means reads can be concurrent with writes. Given this, consider the following time line with a write and two read transactions: write |-X-A--------------| read 1 |---B---| read 2 |---| The write transaction modifies message X and records the wall-clock time of the modification at A. The writer hangs around for a while and later commits its change. Read 1 is concurrent with the write, so it doesn't see the change to X. It does some query and records the wall-clock time of its results at B. Transaction read 2 later starts after the write commits and queries for changes since wall-clock time B (say the reads are performing an incremental backup). Even though read 1 could not see the change to X, read 2 is told (correctly) that X has not changed since B, the time of the last read. In fact, X changed before wall-clock time A, but the change was not visible until *after* wall-clock time B, so read 2 misses the change to X. This is tricky to solve in full-blown snapshot isolation, but because Xapian serializes writes, we can use a simple, monotonically increasing database revision number. Furthermore, maintaining this revision number requires no more IO than a wall-clock time solution because Xapian already maintains statistics on the upper (and lower) bound of each value stream.
2015-08-10build: extract library versions from notmuch.hDavid Bremner
- Make lib/notmuch.h the canonical location for the library versioning information. - Since the release-check should never fail now, remove it to reduce complexity. - Make the version numbers in notmuch.h consistent with the (now deleted) ones in lib/Makefile.local
2015-08-04lib: add public accessor for database from queryDavid Bremner
This is to make it easier for clients of the library to update to the new error code returning versions of notmuch_query_search_messages
2015-08-04lib: deprecate notmuch_query_search_{threads, messages}David Bremner
The CLI (and bindings) code should really be updated to use the new status-code-returning versions. Here are some warnings to prod us (and other clients) to do so.
2015-08-04lib: define NOTMUCH_DEPRECATED macro, document its use.David Bremner
This has been tested with gcc and clang.
2015-08-04lib: Only sync modified message documentsAustin Clements
Previously, we updated the database copy of a message on every call to _notmuch_message_sync, even if nothing had changed. In particular, this always happens on a thaw, so a freeze/thaw pair with no modifications between still caused a database update. We only modify message documents in a handful of places, so keep track of whether the document has been modified and only sync it when necessary. This will be particularly important when we add message revision tracking.
2015-07-28build: add "set -eu" to version script generationDavid Bremner
It turns out that on certain systems like FreeBSD, c++filt is not installed by default. It's basically OK if we fail the build in that case, but what's really not OK is for the build to continue and generate bad binaries.
2015-06-13lib, ruby: make use of -Wl,--no-undefined configurableDavid Bremner
In particular this is supposed to help build on systems (presumably using a non-gnu ld) where this flag is not available.
2015-06-12lib: reject relative paths in n_d_{create,open}_verboseDavid Bremner
There are many places in the notmuch code where the path is assumed to be absolute. If someone (TM) wants a project, one could remove these assumptions. In the mean time, prevent users from shooting themselves in the foot. Update test suite mark tests for this error as no longer broken, and also convert some tests that used relative paths for nonexistent directories.
2015-06-12lib: add NOTMUCH_STATUS_PATH_ERRORDavid Bremner
The difference with FILE_ERROR is that this is for things that are wrong with the path before looking at the disk. Add some 3 tests; two broken as a reminder to actually use this new code.
2015-05-31cli: change "setup" to "set up" where used as a verbJ. Lewis Muir
The word "setup" is a noun, not a verb. Change occurrences of "setup" where used as a verb to "set up".
2015-03-29lib: eliminate fprintf from _notmuch_message_file_openDavid Bremner
You may wonder why _notmuch_message_file_open_ctx has two parameters. This is because we need sometime to use a ctx which is a notmuch_message_t. While we could get the database from this, there is no easy way in C to tell type we are getting.
2015-03-29lib: replace almost all fprintfs in library with _n_d_logDavid Bremner
This is not supposed to change any functionality from an end user point of view. Note that it will eliminate some output to stderr. The query debugging output is left as is; it doesn't really fit with the current primitive logging model. The remaining "bad" fprintf will need an internal API change.
2015-03-29lib: add private function to extract the database for a message.David Bremner
This is needed by logging in functions outside message.cc that take only a notmuch_message_t object.
2015-03-29lib: add a log function with output to a string in notmuch_database_tDavid Bremner
In principle in the future this could do something fancier than asprintf.
2015-03-29lib: add "verbose" versions of notmuch_database_{open,create}David Bremner
The compatibility wrapper ensures that clients calling notmuch_database_open will receive consistent output for now. The changes to notmuch-{new,search} and test/symbol-test are just to make the test suite pass. The use of IGNORE_RESULT is justified by two things. 1) I don't know what else to do. 2) asprintf guarantees the output string is NULL if an error occurs, so at least we are not passing garbage back.
2015-03-13lib: make notmuch_query_count_messages explicitely exactJani Nikula
The default is actually exact if no checkatleast parameter is specified. This change makes that explicit, mainly for documentation, but also to be safe in the unlikely event of a change of default. [ commit message rewritten by db based on id:87lho0nlkk.fsf@nikula.org ]
2015-03-07lib: bump library minor versionDavid Bremner
This should have happened in commit 326e18856, but it didn't.
2015-03-06lib: make notmuch shared library install_name be full path on Mac OS XJ. Lewis Muir
The install_name of libnotmuch.dylib on Mac OS X is what is written into a program that links against it. If it is just the name of the shared library file, as opposed to the full path, the program won't be able to find it when it runs and will abort. Instead, the install_name should be the full path to the shared library (in its final installed location). Why does Notmuch work without this patch when installed via Homebrew? The answer is twofold. One, /usr/local/lib is a special location in which the dynamic linker will look by default to find shared libraries. Homebrew highly recommends installing to /usr/local, and, assuming it has been configured this way, the Notmuch library will end up installed in /usr/local/lib, and the dynamic linker will find it. Two, Homebrew globally corrects all install names in dynamically shared libraries and binaries for each package it installs. So, even if the install names in a package's binaries and libraries are incorrect, Homebrew corrects them automatically, and no one ever knows. Why does Notmuch work without this patch when installed via MacPorts? The answer is that MacPorts applies a patch just like this patch to fix the same problem.
2015-03-01lib: bump SONAME minor versionDavid Bremner
This indicates upwardly compatible changes, namely adding new symbols. Although we don't formally need to do this until the next release, there is no hard in doing it now, as long as we don't bump the minor version for every addition between now and the release.
2015-03-01lib: add new status reporting API for notmuch_query_search_{m,t}David Bremner
This at least allows distinguishing between out of memory and Xapian exceptions. Adding finer grained status codes would allow different Xapian exceptions to be preserved. Adding wrappers allows people to transition gradually to the new API, at the cost of bloating the library API a bit.