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.
typedef struct _filename_node {
char *filename;
typedef struct _filename_node {
char *filename;
struct _filename_node *next;
} _filename_node_t;
struct _filename_node *next;
} _filename_node_t;
_filename_list_t *removed_files;
_filename_list_t *removed_directories;
_filename_list_t *removed_files;
_filename_list_t *removed_directories;
+ _filename_list_t *directory_mtimes;
notmuch_bool_t synchronize_flags;
_filename_list_t *message_ids_to_sync;
notmuch_bool_t synchronize_flags;
_filename_list_t *message_ids_to_sync;
+static _filename_node_t *
_filename_list_add (_filename_list_t *list,
const char *filename)
{
_filename_list_add (_filename_list_t *list,
const char *filename)
{
*(list->tail) = node;
list->tail = &node->next;
*(list->tail) = node;
list->tail = &node->next;
* the database because a message could be delivered later in this
* same second. This may lead to unnecessary re-scans, but it
* avoids overlooking messages. */
* the database because a message could be delivered later in this
* same second. This may lead to unnecessary re-scans, but it
* avoids overlooking messages. */
- if (! interrupted && fs_mtime != stat_time) {
- status = notmuch_directory_set_mtime (directory, fs_mtime);
- if (status && ret == NOTMUCH_STATUS_SUCCESS)
- ret = status;
- }
+ if (fs_mtime != stat_time)
+ _filename_list_add (state->directory_mtimes, path)->mtime = fs_mtime;
add_files_state.removed_files = _filename_list_create (ctx);
add_files_state.removed_directories = _filename_list_create (ctx);
add_files_state.removed_files = _filename_list_create (ctx);
add_files_state.removed_directories = _filename_list_create (ctx);
+ add_files_state.directory_mtimes = _filename_list_create (ctx);
if (! debugger_is_active () && add_files_state.output_is_a_tty
&& ! add_files_state.verbose) {
if (! debugger_is_active () && add_files_state.output_is_a_tty
&& ! add_files_state.verbose) {
+ for (f = add_files_state.directory_mtimes->head; f && !interrupted; f = f->next) {
+ notmuch_directory_t *directory;
+ directory = notmuch_database_get_directory (notmuch, f->filename);
+ if (directory) {
+ notmuch_directory_set_mtime (directory, f->mtime);
+ notmuch_directory_destroy (directory);
+ }
+ }
+
talloc_free (add_files_state.removed_files);
talloc_free (add_files_state.removed_directories);
talloc_free (add_files_state.removed_files);
talloc_free (add_files_state.removed_directories);
+ talloc_free (add_files_state.directory_mtimes);
/* Now that removals are done (hence the database is aware of all
* renames), we can synchronize maildir_flags to tags for all
/* Now that removals are done (hence the database is aware of all
* renames), we can synchronize maildir_flags to tags for all