aboutsummaryrefslogtreecommitdiff
path: root/notmuch.c
AgeCommit message (Collapse)Author
2009-10-25Add an INTERNAL_ERROR macro and use it for all internal errors.Carl Worth
We were previously just doing fprintf;exit at each point, but I wanted to add file and line-number details to all messages, so it makes sense to use a single macro for that.
2009-10-25notmuch dump: Eliminate extra space in error message.Carl Worth
Little details can make big impressions.
2009-10-25Move read-only-archive hint from "notmuch setup" to "notmuch new"Carl Worth
The "notmuch setup" output was getting overwhelmingly verbose. Also, some people might not have a lot of mail, so might never need this optimization. It's much better to move the hint to the time when the user could actually benefit from it, (it's easy to detect that "notmuch new" took more than 1 second, and we know if there are any read-only directories there or not).
2009-10-24Add a preliminary "notmuch search" command.Carl Worth
This isn't behaving at all like it's documented yet, (for example, it's returning message IDs not thread IDs[*]). In fact, the output code is just a copy of the body of "notmuch dump", so all you get for now is message ID and tags. But this should at least be enough to start exercising the query functionality, (which is currently very buggy). [*] I'll want to convert the databse to store thread documents before fixing that.
2009-10-24notmuch setup/new: Propagate failure from notmuch_database_set_timestampCarl Worth
With some recent testing, the timestamp was failing, (overflowing the term limit), and reporting an error, but the top-level notmuch command was still returning a success return value. I think it's high time to add a test suite, (and the code base is small enough that if we add it now it shouldn't be *too* hard to shoot for a very high coverage percentage).
2009-10-24Revert "Remove some unneeded initializers."Carl Worth
This reverts commit fb1bae07002d45138832eacb280419dbd7a19774. These initializers were totally necessary. I clearly wasn't thinking straight when I removed them.
2009-10-23Cut the enthusiasm a bit.Carl Worth
It gets annoying pretty quick.
2009-10-23Make "notmuch new" ignore directories that are read-only.Carl Worth
With this, "notmuch new" is now plenty fast even with large archives spanning many sub-directories. Document this both in "notmuch help" and also in the output of notmuch setup.
2009-10-23add_files: Pull one stat out of the recrusive function.Carl Worth
There's no need to stat each directory both before and after each recursive call.
2009-10-23More fixing of plurals.Carl Worth
It definitely doesn't help that we have the same messages in both "setup" and "new". Should combine those really.
2009-10-23More care in final status reporting.Carl Worth
Printing "Added 1 new messages" just looks like lack of attention to detail, (but yes plurals can be annoying this way).
2009-10-23Print a better message than "0s" for zero seconds.Carl Worth
It's nice to have a tool that at least construct actual sentences.
2009-10-23Add new "notmuch new" command.Carl Worth
Finally, I can get new messages into my notmuch database without having to run a complete "notmuch setup" again. This takes advantage of the recent timestamp capabilities in the database to avoid looking into directories that haven't changed since the last time "notmuch new" was run.
2009-10-23add_files: Change to return a status value instead of voidCarl Worth
Also change to use goto rather than early returns. And once again, there were lots of bugs in the error cases previously.
2009-10-23notmuch setup: Clean up the progress printing a bit.Carl Worth
Get rid of a useless leading 0 on the seconds value, and make a distinction between "files" and "messages", (we process many files, but not all of them are recongized as messages). Finally, add a summary line at the end saying how many unique messages were added to the database. Since this comes right after the total number of files, it gives the user at least a hint as to how many messages were encountered with duplicate message IDs.
2009-10-23Remove some unneeded initializers.Carl Worth
Some people might argue for more initializers to be "safer", but I actually prefer to leave things this way. It saves typing, but the real benefit is that the things that do require initialization stand out so we know to watch them carefully. And with valgrind, we actually get to catch errors earlier if we *don't* initialize them. So that can be "safer" ironically enough.
2009-10-23notmuch setup: Fix a couple of error paths.Carl Worth
We had early returns instead of goto statments, and sure enough, they were leaking. Much cleaner this way.
2009-10-23Add notmuch_database_set_timestamp and notmuch_database_get_timestampCarl Worth
These will be very helpful to implement an efficient "notmuch new" command which imports new mail messages that have appeared.
2009-10-23notmuch restore: Print names of tags that cannot be appliedCarl Worth
This helps the user gauge the severity of the error. For example, when restoring my sup tags I see a bunch of tags missing for message IDs of the form "sup-faked-...". That's not surprising since I know that sup generates these with the md5sum of the message header while notmuch uses the sha-1 of the entire message. But how much will this hurt? Well, now that I can see that most of the missing tags are just "attachment", then I'm not concerned, (I'll be automatically creating that tag in the future based on the message contents). But if a missing tag is "inbox" then that's more concerning because that's data that I can't easily regenerate outside of sup.
2009-10-21Add notmuch_status_to_string function.Carl Worth
Be kind and let the user print error messages, not just error codes.
2009-10-21Implement "notmuch restore".Carl Worth
It's pretty easy to do with all the right infrastructure in place. Now that I can get my tags from sup to notmuch, maybe I'll be able to start reading mail again.
2009-10-21Pull out a chomp_newline function from "notmuch setup"Carl Worth
We'll want this same thing with "notmuch restore", (and really anything using getline).
2009-10-21notmuch dump: Fix to print spaces between tags.Carl Worth
Simple little bug here made all the tags run together.
2009-10-21notmuch dump: Fix buffer overrun in error message.Carl Worth
Just a little bug I noticed while editing nearby code.
2009-10-21notmuch setup: Print a few protecting spaces after progress reports.Carl Worth
This is to help keep the report looking clean when a new report is shorter than a previous reports, (say, when crossing the boundary from over one minute remaining to less than one minute remaining). This used to be here, but I must have accidentally dropped it when reformatting the progress report recently.
2009-10-20query: Remove the magic NOTMUCH_QUERY_ALLCarl Worth
Using the address of a static char* was clever, but really unnecessary. An empty string is much less magic, and even easier to understand as the way to query everything from the database.
2009-10-20notmuch dump: Free each message as it's used.Carl Worth
Previously we were leaking[*] memory in that the memory footprint of a "notmuch dump" run would continue to grow until the output was complete, and then finally all the memory would be freed. Now, the memory footprint is small and constant, O(1) rather than O(n) in the number of messages. [*] Not leaking in a valgrind sense---every byte was still carefully being accounted for and freed eventually.
2009-10-20Implement 'notmuch dump'.Carl Worth
This is a fairly big milestone for notmuch. It's our first command to do anything besides building the index, so it proves we can actually read valid results out from the index. It also puts in place almost all of the API and infrastructure we will need to allow searching of the database. Finally, with this change we are now using talloc inside of notmuch which is truly a delight to use. And now that I figured out how to use C++ objects with talloc allocation, (it requires grotty parts of C++ such as "placement new" and "explicit destructors"), we are valgrind-clean for "notmuch dump", (as in "no leaks are possible").
2009-10-20notmuch: Fix setup so that accepting the default mail path works.Carl Worth
The recent change from GIOChannel to getline, (with a semantic change of the newline terminator now being included in the result that setup_command sees), broke this.
2009-10-20notmuch: Use GNU libc getline() instead of glib GIOChannelCarl Worth
Less reliance on glib is always nice for our memory-leak testing efforts.
2009-10-20Add some explanation about NOTMUCH_BASE to setup_command.Carl Worth
Since we allow the user to enter a custom directory, we need to let the user know how to make this persistent. Of course, a better answer would be to take what the user entered and shove it into a ~/.notmuch-config file or so, but for now this will have to do.
2009-10-20notmuch_database_create/open: Fix to handle NULL as documented.Carl Worth
When documenting these functions I described support for a NOTMUCH_BASE environment variable to be consulted in the case of a NULL path. Only, I had forgotten to actually write the code. This code exists now, with a new, exported function: notmuch_database_default_path
2009-10-19notmuch: Revamp help message a bit.Carl Worth
The big update here is the addition of the dump and restore commands which are next on my list. Also, I've now come up with a syntax for documenting the arguments of sub-commands.
2009-10-19notmuch: Ignore files that don't look like email messages.Carl Worth
This is helpful for things like indexes that other mail programs may have left around. It also means we can make the initial instructions much easier, (the user need not worry about moving away auxiliary files from some other email program).
2009-10-19notmuch: Reword the progress report slightly.Carl Worth
I noticed this style during a recent Debian install and I liked how much less busy it is compared to what we had before, (while still telling the user everything she might want).
2009-10-19Document which pieces of glib we're still using.Carl Worth
Looks like we can copy in a hash-table implementation, (from cairo, say), and then a few _ascii_ functions from glib, (we'll need to switch a few current uses if things like isspace, etc. to locale- independent versions as well). So not too hard to free ourselves of glib for now, (until we add GMime back in later, of course).
2009-10-19notmuch: Ignore .notmuch when counting files.Carl Worth
We were correctly ignoring this when adding files, but not when doing the initial count. Clearly we need better code sharing here.
2009-10-18notmuch: Start actually adding messages to the index.Carl Worth
This is the beginning of the notmuch library as well, with its interface in notmuch.h. So far we've got create, open, close, and add_message (all with a notmuch_database prefix). The current add_message function has already been whittled down from what we have in notmuch-index-message to add only references, message-id, and thread-id to the index, (that is---just enough to do thread-linkage but nothing for full-text searching). The concept here is to do something quickly so that the user can get some data into notmuch and start using it. (The most interesting stuff is then thread-linkage and labels like inbox and unread.) We can defer the full-text indexing of the body of the messages for later, (such as in the background while the user is reading mail). The initial thread-stitching step is still slower than I would like. We may have to stop using libgmime for this step as its overhead is not worth it for the simple case of just parsing the message-id, references, and in-reply-to headers.
2009-10-17Start a new top-level executable: notmuch.Carl Worth
Of course, there's not much that this program does yet. It's got some structure for some sub-commands that don't do anything. And it has a main command that prints some explanatory text and then counts all the regular files in your mail archive.