]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-new.c
notmuch new: Fix to detect deletions of names at the end of the list.
[notmuch] / notmuch-new.c
index 432d126286fba8fd070ad75d18850ecca38caef9..f0c306d58ba8edf55af84f1dd535781e19fad7d8 100644 (file)
@@ -430,6 +430,30 @@ add_files_recursive (notmuch_database_t *notmuch,
        next = NULL;
     }
 
        next = NULL;
     }
 
+    /* Now that we've walked the whole filesystem list, anything left
+     * over in the database lists has been deleted. */
+    while (notmuch_filenames_has_more (db_files))
+    {
+       char *absolute = talloc_asprintf (state->removed_files,
+                                         "%s/%s", path,
+                                         notmuch_filenames_get (db_files));
+
+       _filename_list_add (state->removed_files, absolute);
+
+       notmuch_filenames_advance (db_files);
+    }
+
+    while (notmuch_filenames_has_more (db_subdirs))
+    {
+       char *absolute = talloc_asprintf (state->removed_directories,
+                                         "%s/%s", path,
+                                         notmuch_filenames_get (db_subdirs));
+
+       _filename_list_add (state->removed_directories, absolute);
+
+       notmuch_filenames_advance (db_subdirs);
+    }
+
     if (! interrupted) {
        status = notmuch_directory_set_mtime (directory, fs_mtime);
        if (status && ret == NOTMUCH_STATUS_SUCCESS)
     if (! interrupted) {
        status = notmuch_directory_set_mtime (directory, fs_mtime);
        if (status && ret == NOTMUCH_STATUS_SUCCESS)