aboutsummaryrefslogtreecommitdiffhomepage
path: root/notmuch-new.c
Commit message (Collapse)AuthorAge
* new: Don't report version after upgradeGravatar Austin Clements2014-08-30
| | | | | | | | | | The version number has always been pretty meaningless to the user and it's about to become even more meaningless with the introduction of "features". Hopefully, the database will remain on version 3 for some time to come; however, the introduction of new features over time in version 3 will necessitate upgrades within version 3. It would be confusing if we always tell the user they've been "upgraded to version 3". If the user wants to know what's new, they should read the news.
* new: Report and abort on upgrade failureGravatar Austin Clements2014-08-06
| | | | | Previously the return status of notmuch_database_upgrade went completely unchecked.
* notmuch-new: backup tags before database upgradeGravatar David Bremner2014-04-12
| | | | | | | | All we do here is calculate the backup filename, and call the existing dump routine. Also take the opportunity to add a message about being safe to interrupt.
* cli: make sure notmuch new and insert don't add invalid tagsGravatar Jani Nikula2014-03-06
| | | | | Check new.tags configuration values before doing anything, and bail out on invalid values.
* new: Detect dirent.d_type support at configure timeGravatar Austin Clements2014-02-14
| | | | | | | | Support for dirent.d_type is OS-specific. Previously, we used _DIRENT_HAVE_D_TYPE to detect support for this, but this is apparently a glic-ism (FreeBSD, for example, supports d_type, but does not define this). Since there's no cross-platform way to detect support for dirent.d_type, detect it using a test compile at configure time.
* cli: add --quiet option to notmuch newGravatar Jani Nikula2014-01-26
| | | | | | Tie it to --verbose (resulting in verbosity levels of quiet, normal, and verbose) but leave --debug orthogonal. Do some drive-by cleaning while at it.
* cli: abstract notmuch new result printingGravatar Jani Nikula2014-01-26
| | | | | | The notmuch_new_command() function has grown huge, chop it up a bit. This should also be helpful when adding a --quiet option to notmuch new. No functional changes.
* cli: for loop is more customaryGravatar Jani Nikula2014-01-26
| | | | | With the happy day stop condition within the while, it was confusing. Switch to the paradigm for loop. No functional changes.
* cli: use dirent_type in count_files tooGravatar Jani Nikula2014-01-26
| | | | | Avoid an extra stat per file, if possible, also when counting the files for initial indexing.
* cli: only check the ignore list if neededGravatar Jani Nikula2014-01-26
| | | | | Premature optimization is the root of all evil, but this is simple enough.
* cli: extract single message addition in notmuch new to clarify codeGravatar Jani Nikula2014-01-26
| | | | | The add_files() function has grown huge, chop it up a bit. No functional changes.
* cli: clean up exit status code returned by the cli commandsGravatar Jani Nikula2014-01-18
| | | | | | Apart from the status codes for format mismatches, the non-zero exit status codes have been arbitrary. Make the cli consistently return either EXIT_SUCCESS or EXIT_FAILURE.
* new: Don't scan unchanged directories with no sub-directoriesGravatar Austin Clements2013-10-28
| | | | | | This can substantially reduce the cost of notmuch new in some situations, such as when the file system cache is cold or when the Maildir is on NFS.
* cli: move config open/close to main() from subcommandsGravatar Jani Nikula2013-03-08
| | | | | | | | | | | | | This allows specifying config file as a top level argument to notmuch, and generally makes it possible to override config file options in main(), without having to touch the subcommands. If the config file does not exist, one will be created for the notmuch main command and setup and help subcommands. Help is special in this regard; the config is created just to avoid errors about missing config, but it will not be saved. This also makes notmuch config the talloc context for subcommands.
* cli: config: make notmuch_config_open() "is new" parameter input onlyGravatar Jani Nikula2013-03-07
| | | | | | | | We now have a notmuch_config_is_new() function to query whether a config was created or not. Change the notmuch_config_open() is_new parameter into boolean create_new to determine whether the function should create a new config if one doesn't exist. This reduces the complexity of the API.
* cli: convert "notmuch new" to the argument parserGravatar Jani Nikula2012-12-04
| | | | | | Use the notmuch argument parser to handle arguments in "notmuch new". As a side effect, this fixes broken STRNCMP_LITERAL usage that accepts, for example, --verbosefoo for --verbose.
* new: Skip ignored broken symlinksGravatar Austin Clements2012-11-26
| | | | | | | | | We now test for user ignore patterns before attempting to determine if a directory entry is itself a directory. As a result, we no longer abort for broken symlinks if the user has explicitly ignored them. This fixes the test added in the previous patch. It also slightly changes the debug output checked by another test of ignores.
* cli: notmuch new: optionally output debug information when ignoring ↵Gravatar Pieter Praet2012-10-20
| | | | | | | files/directories When running 'notmuch new' with the '--debug' option, output debug information regarding explicitly ignored files and directories.
* cli: add '--debug' option to 'notmuch new'Gravatar Pieter Praet2012-10-20
| | | | | This will be used in later patches to test the 'new.ignore' config option more thoroughly.
* new: Unify add_files and add_files_recursiveGravatar Austin Clements2012-05-24
| | | | | | | | Since starting at the top of a directory tree and recursing within that tree are now identical operations, there's no need for both add_files and add_files_recursive. This eliminates add_files (which did nothing more than call add_files_recursive after the previous patch) and renames add_files_recursive to add_files.
* new: Merge error checks from add_files and add_files_recursiveGravatar Austin Clements2012-05-24
| | | | | | | | | | | | Previously, add_files_recursive could have been called on a symlink to a non-directory. Hence, calling it on a non-directory was not an error, so a separate function, add_files, existed to fail loudly in situations where the path had to be a directory. With the new stat-ing logic, add_files_recursive is always called on directories, so the separation of this logic is no longer necessary. Hence, this patch moves the strict error checking previously done by add_files into add_files_recursive.
* new: Centralize file type stat-ing logicGravatar Austin Clements2012-05-24
| | | | | | | | | | This moves our logic to get a file's type into one function. This has several benefits: we can support OSes and file systems that do not provide dirent.d_type or always return DT_UNKNOWN, complex symlink-handling logic has been replaced by a simple stat fall-through in one place, and the error message for un-stat-able file is more accurate (previously, the error always mentioned directories, even though a broken symlink is not a directory).
* new: Remove workaround for detecting newly created directory objectsGravatar Austin Clements2012-05-23
| | | | | | | | | | Previously, notmuch_database_get_directory did not indicate whether or not the returned directory object was newly created, which required a workaround to distinguish newly created directory objects with no child messages from directory objects that had no mtime set but did have child messages. Now that notmuch_database_get_directory distinguishes whether or not the directory object exists in the database, this workaround is no longer necessary.
* 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/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.
* Use notmuch_database_destroy instead of notmuch_database_closeGravatar Justus Winter2012-04-28
| | | | | | Adapt the notmuch binaries source to the notmuch_database_close split. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* new: Fix missing end_atomic in remove_filename on errorGravatar Austin Clements2012-04-24
| | | | | | | Previously, if we failed to find the message by filename in remove_filename, we would return immediately from the function without ending its atomic block. Now this code follows the usual goto DONE idiom to perform cleanup.
* new: Print final fatal error message to stderrGravatar Austin Clements2012-04-24
| | | | | | | This was going to stdout. I removed the newline at the beginning of printing the fatal error message because it wouldn't make sense if you were only looking at the stderr stream (e.g., you had redirected stdout to /dev/null).
* new: Handle fatal errors in remove_filename and _remove_directoryGravatar Austin Clements2012-04-24
| | | | | Previously such errors were simply ignored. Now they cause an immediate cleanup and abort.
* new: Consistently treat fatal errors as fatalGravatar Austin Clements2012-04-24
| | | | | | | Previously, fatal errors in add_files_recursive were not treated as fatal by its callers (including itself!). This makes add_files_recursive errors consistently fatal and updates all callers to treat them as fatal.
* add support for user-specified files & directories to ignoreGravatar Tomi Ollila2012-02-17
| | | | | | | | | A new configuration key 'new.ignore' is used to determine which files and directories user wants not to be scanned as new mails. Mark the corresponding test as no longer broken. This work merges my previous attempts and Andreas Amann's work in id:"ylp7hi23mw8.fsf@tyndall.ie"
* Free the results of scandir()Gravatar Ethan Glasser-Camp2012-02-14
| | | | | | | | | | scandir() returns "strings allocated via malloc(3)" which are then "collected in array namelist which is allocated via malloc(3)". Currently we just free the array namelist. Instead, free all the entries of namelist, and then free namelist. entry only points to elements of namelist, so we don't free it separately.
* Silence buildbot warnings about unused resultsGravatar Austin Clements2012-01-21
| | | | | | | | | | | This ignores the results of the two writes in sigint handlers even harder than before. While my libc lacks the declarations that trigger these warnings, this can be tested by adding the following to notmuch.h: __attribute__((warn_unused_result)) ssize_t write(int fd, const void *buf, size_t count);
* 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.
* cli: add support for pre and post notmuch new hooksGravatar Jani Nikula2011-12-11
| | | | | | | | | | | | | | Run notmuch new pre and post hooks, named "pre-new" and "post-new", if present in the notmuch hooks directory. The hooks will be run before and after incorporating new messages to the database. Typical use cases for pre-new and post-new hooks are fetching or delivering new mail to the maildir, and custom tagging of the mail incorporated to the database. Also add command line option --no-hooks to notmuch new to bypass the hooks. Signed-off-by: Jani Nikula <jani@nikula.org>
* cli: change argument parsing convention for subcommandsGravatar David Bremner2011-10-22
| | | | | | | | | previously we deleted the subcommand name from argv before passing to the subcommand. In this version, the deletion is done in the actual subcommands. Although this causes some duplication of code, it allows us to be more flexible about how we parse command line arguments in the subcommand, including possibly using off-the-shelf routines like getopt_long that expect the name of the command in argv[0].
* 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()
* new: Wrap adding and removing messages in atomic sections.Gravatar Austin Clements2011-09-24
| | | | | | This addresses atomicity of tag synchronization, the last atomicity problems in notmuch new. Each message add or remove is wrapped in its own atomic section, so interrupting notmuch new doesn't lose progress.
* new: Synchronize maildir flags eagerly.Gravatar Austin Clements2011-09-24
| | | | | | | | | | | | Because flag synchronization is stateless, it can be performed at any time as long as it's guaranteed to be performed after any change to a message's filename list. Take advantage of this to synchronize tags immediately after a filename is added or removed. This does not yet make adding or removing a message atomic, but it is a big step toward atomicity because it reduces the window where the database tags are inconsistent from nearly the entire notmuch-new to just around when the message is added or removed.
* new: Cleanup. De-duplicate file name removal code.Gravatar Austin Clements2011-09-24
| | | | | | | | | Previously, file name removal was implemented identically in two places. Now it's captured in one function. This is important because file name removal is about to get slightly more complicated with eager tag synchronization and correct removal atomicity.
* new: Cleanup. Put removed/renamed message count in add_files_state_t.Gravatar Austin Clements2011-09-24
| | | | | | Previously, pointers to these variables were passed around individually. This was okay when only one function needed them, but we're about to need them in a few more places.
* lib: Add support for nested atomic sections.Gravatar Austin Clements2011-09-23
| | | | | | | notmuch_database_t now keeps a nesting count and we only start a transaction or commit for the outermost atomic section. Introduces a new error, NOTMUCH_STATUS_UNBALANCED_ATOMIC.
* new: Defer updating directory mtimes until the end.Gravatar Austin Clements2011-09-23
| | | | | | | | Previously, if notmuch new were interrupted between updating the directory mtime and handling removals from that directory, a subsequent notmuch new would not handle those removals until something else changed in that directory. This defers recording the updated mtime until after removals are handled to eliminate this problem.
* new: Don't lose messages on SIGINT.Gravatar Austin Clements2011-09-13
| | | | | | | | Previously, message removals were always performed, even after a SIGINT. As a result, when a message was moved from one folder to another, a SIGINT between processing the directory the message was removed from and processing the directory it was added to would result in notmuch removing that message from the database.
* new: Improved workaround for mistaken new directoriesGravatar Austin Clements2011-06-29
| | | | | | | | | | | | | Currently, notmuch new assumes any directory with a database mtime of 0 is new, but we don't set the mtime until after processing messages and subdirectories in that directory. Hence, anything that prevents the mtime update (such as an interruption or the wall-clock logic introduced in 8c39e8d6) will cause the next notmuch new to think the directory is still new. We work around this by setting the new directory's database mtime to -1 before scanning anything in the new directory. This also obviates the need for the workaround used in 8c39e8d6.
* new: Don't update DB mtime if FS mtime equals wall-clock time.Gravatar Austin Clements2011-06-29
| | | | | | | | | | | | | | | | This fixes a race where multiple message deliveries in the same second with an intervening notmuch new could result in messages being ignored by notmuch (at least, until a later delivery forced a rescan). Because mtimes only have second granularity, later deliveries in the same second won't change the directory mtime, and hence won't trigger notmuch new to rescan the directory. This situation can only occur when notmuch new is being run at the same second as the directory's modification time, so simply don't update the saved mtime in this case. This very race happens all over the test suite, and is currently compensated for with increment_mtime (and, occasionally, luck). With this change, increment_mtime becomes unnecessary.
* fix sum moar typos [comments in source code]Gravatar Pieter Praet2011-06-23
| | | | | | | | | | Various typo fixes in comments within the source code. Signed-off-by: Pieter Praet <pieter@praet.org> Edited-by: Carl Worth <cworth@cworth.org> Restricted to just source-code comments, (and fixed fix of "descriptios" to "descriptors" rather than "descriptions").
* Remove some variables which were set but not used.Gravatar Carl Worth2011-05-11
| | | | | | | | | | | | gcc (at least as of version 4.6.0) is kind enough to point these out to us, (when given -Wunused-but-set-variable explicitly or implicitly via -Wunused or -Wall). One of these cases was a legitimately unused variable. Two were simply variables (named ignored) we were assigning only to squelch a warning about unused function return values. I don't seem to be getting those warnings even without setting the ignored variable. And the gcc docs. say that the correct way to squelch that warning is with a cast to (void) anyway.
* new: Update comments for add_files_recursiveGravatar Carl Worth2011-03-10
| | | | | | The most recent commit optimized the implementation of this function. This commit simply updates the relevant comments to match the new implementation.